Felix Krull runs a PPA offering basically any version of Python (seriously, there is 2.3.7 build for vivid...) for many Ubuntu releases at https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa.

Do the usual:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.5

It will not overwrite your existing python3.4 which is still symlinked as python3.

Instead, to run python3.5, run the command python3.5 (or python3.X for any other version of python).


DON'T change the symlink! There are apparently many system functions that don't work properly with python3.5.

I tried this and afterwards couldn't open a terminal, software updater,...

cd /usr/bin
sudo rm python3

The upgrade to Wily will adapt the meta-package python3 to point to python3.5. I don't expect any breakage, but at this point the foreign repository is not needed anymore. So to be really safe, you can purge the PPA before doing the upgrade.

Answer from Nephente on askubuntu.com
Discussions

Installing specific python version in Ubuntu 20
You can use pyenv to install different versions of python and it allows you to change your global python version easily using "shims" or it can even change your python version per project. If you use pyenv and pipenv you can easily create python venvs with specific python version. I highly recommend both tools. More on reddit.com
🌐 r/Python
2
0
June 21, 2020
How to install a specific Python version on Ubuntu?
In some cases, you might need to install a very specific Python version on your Ubuntu server which might be different from the one that comes from the defau… More on digitalocean.com
🌐 digitalocean.com
1
March 1, 2021
Install python 3.11.9 on ubuntu
According to this page: 'Python 3.11.9 is the newest major release of the Python programming language". Can I install Python 3.11.9 in my Virtual Machine? I have installed guest VM ubuntu-22.04.4-desktop-amd64.iso on a Windows 10 host. In the VM, I have run the following: sudo apt install sudo ... More on discuss.python.org
🌐 discuss.python.org
12
1
April 16, 2024
linux - apt-get install for different python versions - Stack Overflow
However, what you usually want is to set a specific python and package version on a per-project basis. This is how to do it. First install your desired Python version as before. Then, from inside your project directory, set the desired python version with: ... And now let's install a package locally just for our project: TODO: there is no nice way it seems: Pyenv choose virtualenv directory · Now, when someone wants to use your project, they will do: ... Tested on Ubuntu ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/python › installing specific python version in ubuntu 20
r/Python on Reddit: Installing specific python version in Ubuntu 20
June 21, 2020 -

Beginners beware, this post isn't about overwriting the default python installation, but working with alternative installation of other versions of python on your Ubuntu 20. If you overwrite your default python you are likely to encounter several other issues that may cause you to reinstall your OS, so please go through the complete post and try to make alternate installation.

In this post, I am going to write about a way to install specific python version (python 3.7.5) in your Ubuntu 20 system which initially has Python 3.8. Since, the project I have done till now had the Python version of 3.6 and 3.7. But, after I updated my OS to Ubuntu 20, my virtual environment could not be set upped as per the project requirements.

Because I wanted my old projects to be compatible, first, I thought of way to override my python 3.8 with python 3.7 but had so many other issues.

Now, I have found a way to deal with this version issue, which I will be explaining below.

1 Checking, Initial version of Python that comes with Ubuntu 20

$ python3 --version
Python 3.8.2

2 Installation of pip

a. First updating the packages

$ sudo apt update

b. Installation of pip

# The command below will install all the dependencies required for building Python modules.
$ sudo apt install python3-pip

c. Verification of pip installed

$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

3 Install virtualenv in your local system

Virtualenv is where all the packages required for project will be kept without dealing with local system packages.

$ pip3 install virtualenv

If you want to use Python 3.8 in your project, then, below process can be followed.

# my_project is the project directory
$ mkdir my_project && cd my_project

# Create a virtual environment in your project directory
$ python3 -m virtualenv .venv

# Activating the environment
$ source .venv/bin/activate
$ python --version
Python 3.8.2

But, this isn't our objective, we want to use other python version (Lets say Python 3.7.5). So, for that please see the below steps.

First install specific version of python in your local system without causing conflict in local system

# Update and Upgrades of packages
$ sudo apt update  
$ sudo apt upgrade -y

# Next, install the build tools and Python 3.7 dependencies using the following command:
$ sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev

# Next, download the source code of Python 3.7 using the wget tool:
$ cd /tmp
$ wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz

# Next, decompress the tar file using:
$ tar xf Python-3.7.5.tar.xz

# Next, navigate inside your decompressed Python-3.7.0 folder:
$ cd Python-3.7.5

# Build Python 3.7.5 code using the configure and make tools:
$ ./configure --enable-optimizations
$ sudo make -j 8

# Next, run the following command to install the Python 3.7.5:
# Prefer "altinstall" than "install" because install will override the current OS python, and will cause other conflicts in OS.
$ sudo make altinstall


# Python 3.7.5 can run using:
$ python3.7 

After the specific version of python is installed successfully.

Create virtual environment in your project with specific version installed

# First know your specific python version installed path
$ which python3.7
/usr/local/bin/python3.7

# my_project is a project directory
$ mkdir my_project && cd my_project

# Create virtualenv with the specific python version path
$ python3 -m virtualenv --python=/usr/local/bin/python3.7 .venv

# Activating the virtualenv 
$ source .venv/bin/activate

# Test the python path and version
$ which python
my_project/.venv/bin/python

# python --version
Python 3.7.5

Now can work on any project as required.

Would like to get recommendation on this process, or any other ways it can be dealt with.

🌐
Ruan Bekker's Blog
ruan.dev › blog › 2022 › 06 › 23 › install-a-specific-python-version-on-ubuntu
Install a specific Python version on Ubuntu | Ruan Bekker's Blog
June 23, 2022 - In this short tutorial, I will demonstrate how to install a spcific version of Python on Ubuntu Linux.
🌐
DigitalOcean
digitalocean.com › community › questions › how-to-install-a-specific-python-version-on-ubuntu
How to install a specific Python version on Ubuntu? | DigitalOcean
March 1, 2021 - This is going to be beyond the scope of the tutorial. However here is how you could install a specific version if needed: ... Finally you can create a symlink for that specific Python version so that you could use the binary from anywhere:
🌐
Clouding.io
help.clouding.io › hc › en-us › articles › 13555555842588-How-to-install-different-versions-of-Python-on-Ubuntu
How to install different versions of Python on Ubuntu – Clouding.io
May 1, 2024 - This command will install the latest stable version of Python 3 available in the Ubuntu repositories: ... If you need to install specific versions of Python or work with multiple versions of Python on your system, a popular option is to use pyenv.
Find elsewhere
🌐
Educative
educative.io › answers › how-to-install-a-specific-python-version-in-linux
How to install a specific Python version in Linux
We can check the default version of Python by running the command python --version. Open a terminal window and update the package list: ... Replace <version> with the version number you want to install.
🌐
Linux Hint
linuxhint.com › install-specific-python-version-ubuntu
How to install a specific Python version on Ubuntu – Linux Hint
Having successfully downloaded a specific version of Python, the final steps are simple and easy. First, we will extract the package through the command below. ... You can replace the version number as Python-version.tgz according to your package. The next steps include opening the Python directory, configuring the files, and installing it.
🌐
Python.org
discuss.python.org › python help
Install python 3.11.9 on ubuntu - Python Help - Discussions on Python.org
Can I install Python 3.11.9 in my Virtual Machine? I have installed guest VM ubuntu-22.04.4-desktop-amd64.iso on a Windows 10 host. In the VM, I have run the following: sudo apt install sudo ...
Published   April 16, 2024
🌐
BitLaunch
bitlaunch.io › blog › how-to-install-python-on-ubuntu
7 Ways to Install and Manage Python and Python3 on Ubuntu
March 5, 2026 - First, install software-properties-common. This will give us access to the command we need to install the PPA: ... With that, you can install any Python version you like via apt by specifying the version number.
Top answer
1 of 3
11

Python has got its own package managing facilities, in parallel to the one sets by the Linux distributions (including Ubuntu). The repository is the Pypi - Python Package Index, and packages are installed with pip or the easy_install script, which is part of Python's setuptools package.

As a rule of thumb, you should not use both the packages installed via pip/setuptools, and packages available to your distro (via apt-get, yum, urpmi, etc...) as they might conflict.

So, one of the less error prone way to deal with it is to have separate Python installs in your system - leave the python that came with the system for system scripts and such - on this python, make use of packages installed by your package manager only. And install other versions of Python (or even the same), to be run with "virtualenv"s - on these other install you install things with pip/setuptools only.

(And even if one opt to live boldly and not use virtualenvs, installing another python version on the same prefix (/usr, and even /usr/local) than your system's Python is a source to confusing errors and conflicts).

Note that the Debian - and Ubuntu - systems devised a way to run parallel official Python's in /usr, and to have apt-get to install Python packages to both Python versions at once. This mostly works, but they mess with Python's default directory hierarchy, and some applications fail to use Python in this way. (It is also a mess to find the module files themselves in a Debian or Ubuntu). So the above method apply as a recommendation even if your system do have more than one version of Python available on apt-get.

In short, once you have compiled your desired version of Python, do this:

  1. use your system's package manager to install "python-setuptools" and "python-virtualenv" (not sure if these are the actual package names).
  2. Use virtualenv to create an environment from which you will use your different Python version
  3. Activate your virtualenv, and install Python packages using pip on it.

Virtualenv does feature a "--help" switch to help you, but you basically do:

Copy$ virtualenv -p <path-to-python-interpreter>  <environment-dir>
$ source <environment-dir>/bin/activate

And there you are - all things using Python will "see" the interpreter in the virtualenv, due to environment variables set.

2 of 3
6

ubuntu 10.04 doesn't have a python2.7 package. You have to build 2.7 yourself. I did read an article about ubuntu releasing a python2.7 package when 12.04 came out but i'm not sure what the repository location is.

http://eli.thegreenplace.net/2011/10/10/installing-python-2-7-on-ubuntu/

or:

Copysudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.7

https://askubuntu.com/questions/101591/install-python-2-7-2-on-ubuntu-10-04-64-bit

this question has lots of answers online.

🌐
Reddit
reddit.com › r/ubuntu › installing specific version of python in ubuntu 20
r/Ubuntu on Reddit: Installing specific version of Python in Ubuntu 20
June 21, 2020 -

Beginners beware, this post isn't about overwriting the default python installation, but working with alternative installation of other versions of python on your Ubuntu 20. If you overwrite your default python you are likely to encounter several other issues that may cause you to reinstall your OS, so please go through the complete post and try to make alternate installation.

In this post, I am going to write about a way to install specific python version (python 3.7.5) in your Ubuntu 20 system which initially has Python 3.8. Since, the project I have done till now had the Python version of 3.6 and 3.7. But, after I updated my OS to Ubuntu 20, my virtual environment could not be set upped as per the project requirements.

Because I wanted my old projects to be compatible, first, I thought of way to override my python 3.8 with python 3.7 but had so many other issues.

Now, I have found a way to deal with this version issue, which I will be explaining below.

1 Checking, Initial version of Python that comes with Ubuntu 20

$ python3 --version
Python 3.8.2

2 Installation of pip

a. First updating the packages

$ sudo apt update

b. Installation of pip

# The command below will install all the dependencies required for building Python modules.
$ sudo apt install python3-pip

c. Verification of pip installed

$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

3 Install virtualenv in your local system

Virtualenv is where all the packages required for project will be kept without dealing with local system packages.

$ pip3 install virtualenv

If you want to use Python 3.8 in your project, then, below process can be followed.

# my_project is the project directory
$ mkdir my_project && cd my_project

# Create a virtual environment in your project directory
$ python3 -m virtualenv .venv

# Activating the environment
$ source .venv/bin/activate
$ python --version
Python 3.8.2

But, this isn't our objective, we want to use other python version (Lets say Python 3.7.5). So, for that please see the below steps.

First install specific version of python in your local system without causing conflict in local system

# Update and Upgrades of packages
$ sudo apt update  
$ sudo apt upgrade -y

# Next, install the build tools and Python 3.7 dependencies using the following command:
$ sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev libffi-dev

# Next, download the source code of Python 3.7 using the wget tool:
$ cd /tmp
$ wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz

# Next, decompress the tar file using:
$ tar xf Python-3.7.5.tar.xz

# Next, navigate inside your decompressed Python-3.7.0 folder:
$ cd Python-3.7.5

# Build Python 3.7.5 code using the configure and make tools:
$ ./configure --enable-optimizations
$ sudo make -j 8

# Next, run the following command to install the Python 3.7.5:
# Prefer "altinstall" than "install" because install will override the current OS python, and will cause other conflicts in OS.
$ sudo make altinstall


# Python 3.7.5 can run using:
$ python3.7 

After the specific version of python is installed successfully.

Create virtual environment in your project with specific version installed

# First know your specific python version installed path
$ which python3.7
/usr/local/bin/python3.7

# my_project is a project directory
$ mkdir my_project && cd my_project

# Create virtualenv with the specific python version path
$ python3 -m virtualenv --python=/usr/local/bin/python3.7 .venv

# Activating the virtualenv 
$ source .venv/bin/activate

# Test the python path and version
$ which python
my_project/.venv/bin/python

# python --version
Python 3.7.5

Now can work on any project as required.

Would like to get recommendation on this process, or any other ways it can be dealt with.

🌐
Quora
quora.com › How-can-one-install-a-specific-version-of-Python-in-Ubuntu
How can one install a specific version of Python in Ubuntu? - Quora
Answer (1 of 5): Yes we can install any specific version of Python. First install dependencies: [code]sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev [/code]Then downl...
🌐
RoseHosting
rosehosting.com › home › how to install and switch python versions on ubuntu 20.04
How to Install and Switch Python Versions on Ubuntu 20.04 | RoseHosting
October 5, 2022 - In the first step of this tutorial we are going to install the default Python2 and Python3 versions in Ubuntu 20.04.
🌐
OneUptime
oneuptime.com › home › blog › how to install multiple python versions on ubuntu with pyenv
How to Install Multiple Python Versions on Ubuntu with pyenv
January 15, 2026 - # Create project directory mkdir ~/projects/webapp && cd ~/projects/webapp # Install desired Python version if not already installed pyenv install 3.12.1 # Create project-specific virtualenv pyenv virtualenv 3.12.1 webapp-env # Set as local ...
🌐
Medium
medium.com › analytics-vidhya › how-to-install-and-switch-between-different-python-versions-in-ubuntu-16-04-dc1726796b9b
How to install and switch between different python versions in ubuntu 16.04. | by Md Mahbubur Rahman | Analytics Vidhya | Medium
February 8, 2024 - We will set the priority by the following commands: sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2sudo update-alternatives --install ...
🌐
eUKhost
eukhost.com › home › how to install and switch python versions on ubuntu 22.04
How to install and switch Python versions on Ubuntu - eukhost
January 16, 2025 - This indicates that Python 3.6 is not available in the default repository of Ubuntu 22.04. Therefore, we need to download the build from the source. To do so, execute the following command: cd /opt wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz tar xfv Python-3.6.9.tgz cd /Python-3.6.9 · Before continuing with the installation, we must install the prerequisites for the older Python versions:
🌐
LinuxHostSupport
linuxhostsupport.com › home › how to install and switch python versions on ubuntu 22.04
How to Install and Switch Python Versions on Ubuntu 22.04 | LinuxHostSupport
August 29, 2023 - I already installed python 3.10, 3.6 and 3.5 however the pip only point out to python3.10. ... You can use the following command to install a package on a specific Python version: python3.6 -m pip install “package”
🌐
It's FOSS
itsfoss.com › pyenv-ubuntu
Install Multiple Python Versions on Ubuntu With Pyenv
June 14, 2024 - You can have multiple Python versions installed thanks to a tool called pyenv. In this tutorial, I'll show you how to install and use this tool to get more than one Python version simultaneously on your Ubuntu and Debian-based distributions.