Raspberry Pi Zero W – Python issues

So I’m working on a quick and dirty Raspberry Pi Zero W based status light, and ran into some issues.

First of all, the version that ships with Raspberian OS light is version 2.7 of python.. that’s old, so let’s fix it.

After logging in I do a:

sudo bash

This is because I’m lazy and don’t want to type it all the time. I’ve been using unix for too long to not have a root account.. bad practice, but I’ve been using it that way since SCO unix was cool.

First thing is to run the update by doing the following:

root@raspberrypi:~# apt update
root@raspberrypi:~# apt list --upgradable
root@raspberrypi:~# apt upgrade

Now make sure Python 3 is installed

root@raspberrypi:~# apt install python3

but after the update, let’s check…

root@raspberrypi:~# python --version
 Python 2.7.16
root@raspberrypi:~# ls -l /usr/bin/python
 lrwxrwxrwx 1 root root 7 Mar 4 2019 /usr/bin/python -> python2

Well… that’s dumb… but looking into it more it looks like /usr/bin/python is just a symbolic link.

root@raspberrypi:~# rm /usr/bin/python
root@raspberrypi:~# ln -s /usr/bin/python3 /usr/bin/python
root@raspberrypi:~# ls -l /usr/bin/python
 lrwxrwxrwx 1 root root 16 Jan 18 07:01 /usr/bin/python -> /usr/bin/python3
root@raspberrypi:~# python --version
 Python 3.7.3

That part is all fixed now…