Python 3.5.1 came out on December 7th 2015 and as a beginning Python coder I would like to try the very latest version on my Ubuntu installation. At the moment Wily Werewolf 15.10 ships version 3.4 and there are some great improvements in the newest version.
I am currently running Wily Werewolf and I would be keen to hear some methods to update Python to 3.5.1.
Solution 1: Use Docker
I would suggest that you use Docker If you would like to test out a newer version of Python without overwriting your system Python (which it is very important that you don't, because Python 2.x and 3.x are different enough that 3.x will have breaking changes and will cause problems for packages that depend on Python 2.x)
Docker is a way to run lightweight Linux applications in a containerized way. Think of them like a more lightweight Virtual Machine, or a
chroot
with a layered union filesystem plus the management & system resource separation provided bycgroups
.docker pull python:<your_version_here>
docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp python:<your_version_here> python your-daemon-or-script.py
If you develop an application that you'd like to package up (optionally with dependencies) inside a container, you can create a
Dockerfile
with build & dependency setup instructions, then build an image to distribute on Docker Hub. Doing so is a bit beyond the scope of your question, but thedocker-library/python
docs give a quick summary for how to get started.Solution 2: Use packages from the "dead snakes" PPA
There is an archive of old & new versions of Python here. To install an alternate version of Python:
apt-get -y install software-properties-common
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get -y install python<your_version_here> python<your_version_here>-dev
python<your_version_here> your-daemon-or-script.py
/usr/bin/python3.5 your-daemon-or-script.py
If you need to install a specific minor version of the package, you can find the available versions with
apt-cache madison
. For example, let's say we wanted to install a specific version ofpython3.4
: