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.
Better make like this, full command.
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\nexport PATH="/root/.pyenv/bin:$PATH"\neval "$(pyenv init -)"\neval "$(pyenv virtualenv-init -)"\nfi' >> ~/.bash_profile
. ~/.bash_profile