Debian Jessie does not come with the correct Python version out of the box, and instead comes with Python 2. To be able to install Python 3(.5), we have a few options. We could build and install from source, but as per Debian's website, we shouldn't do this. Instead, we will use pyenv, a tool that allows users to switch Python versions easily without breaking their system.
To install pyenv, we will use the official installer.
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
Using pyenv, we can install specific Python versions. pyenv will build these from source using python-build, but won't install them in a way that overwrites the system's version.
pyenv install 3.5.2
If you have issues with this, or you need another Python version, you can see available versions by running pyenv install --list
.
Now we've installed the correct version, setting the version of Python we wish to use system-wide is as simple as running this command:
pyenv global 3.5.2
To test that this worked, try running the command python --version
on your system to confirm the version being used.
You should have now installed Python 3.5 on Debian Jessie.
I am using this on docker. It will probably stop working when they remove the APT packages to the old repositories. Then, it will need further fixes. This also installs a specific cmake and conan versions as example because they are quite difficult to setup. It is required to always pin the python and conan versions because they continually break the packages they use.
This is the log of the last build I did using this
Dockerfile
: