What is the easiest way to install Python 3 on Ubuntu?
The quickest way is to run sudo apt install python3 in the terminal and let the package manager do the rest.
Does Ubuntu ship with Python already installed?
Yes, nearly every version of Ubuntu has Python 3 on board from the first boot, though you might later want to upgrade it or grab a special build for your project.
Can I install multiple Python versions on Ubuntu?
Definitely; you can have Python 3.10, 3.12, and 3.13 all installed at once by using PPAs or compiling manually, then you pick the one you need with update-alternatives or a virtual environment.
Videos
As the package description you linked to says:
In Ubuntu, all python packages use explicit python3 or python2 interpreter and do not use unversioned /usr/bin/python at all ... No packages may declare dependencies on this package.
So, all official Ubuntu packages will depend explicitly on "python2" or "python3", and invoke the appropriate command. The default "python" command is deliberately undefined so that any scripts referencing it have to be updated to unambiguously depend on one version or the other.
However, users may have code that relies on the "python" command being available, and know that they can safely point it across their whole system to one version or the other. The python-is-python3 package (and its counterpart, python-is-python2) are a convenient way to set up a symlink for this purpose.
Does python-is-python3 really just create a single symlink? It seems odd to introduce a package for such a bare bones purpose.
Linux distributions are extremely complex systems made up of a large number of simple components. The power of package managers comes in their flexibility to do simple things like this in a unified way. For instance, a server setup script might have a long list of apt packages that an application needs to be installed, and can simply include python-is-python3 in that list. Shipping a package for this purpose is considerably simpler than having a user guide explaining how to manage the symlink manually.
Does the same go for
pip, i.e.pipinstead ofpip3?
Apparently not - according to this LaunchPad bug, the python3 package automatically points pip at pip3 anyway.
If you open up the .deb file for the package (I used 7-Zip), you can see that apart from some documentation, it really does just contain one symlink, to be installed at /usr/bin/python, pointing to /usr/bin/python3.
In Ubuntu, all python packages use explicit python3 or python2 interpreter and do not use unversioned /usr/bin/python at all. Some third-party code is now predominantly python3 based, yet may use /usr/bin/python.
python-is-python3 is a convenience package which ships a symlink to point the /usr/bin/python interpreter at the current default python3. It may improve compatibility with other modern systems, while breaking some obsolete or third-party software.
python-is-python3 replaces: python, python-is-python2.
I installed python-is-python3 as a convenience package in Ubuntu 20.04, but I later uninstalled it after python2.7 was automatically installed as a dependency of another package.
Go to python3 dist-package directory
cd /usr/lib/python3/dist-packages
And then link these two files
sudo ln -s apt_inst.cpython-35m-x86_64-linux-gnu.so apt_inst.so
sudo ln -s apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so
I had the same problem when I had two versions of python3 installed - python3.7 and python3.9. After uninstalling the older version the problem went away.
Ubuntu 12.10+ and Fedora 13+ have a package called python3-pip which will install pip-3.2 (or pip-3.3, pip-3.4 or pip3 for newer versions) without needing this jumping through hoops.
I came across this and fixed this without needing the likes of wget or virtualenvs (assuming Ubuntu 12.04):
- Install package
python3-setuptools: runsudo aptitude install python3-setuptools, this will give you the commandeasy_install3. - Install pip using Python 3's setuptools: run
sudo easy_install3 pip, this will give you the commandpip-3.2like kev's solution. - Install your PyPI packages: run
sudo pip-3.2 install <package>(installing python packages into your base system requires root, of course). - …
- Profit!
You may want to build a virtualenv of python3, then install packages of python3 after activating the virtualenv. So your system won't be messed up :)
This could be something like:
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install package-name
What’s the right way to install Python 3.12 on Ubuntu 24.04, with pip and venv working out of the box?
I tried:
sudo apt install python3.12.3
But it didn’t include pip or venv, and I hit an “externally managed environment” error when using pip in a venv.
Should I be using:
sudo apt install python3-full
or:
sudo apt-get install python3 python3-dev instead?
Just looking for the cleanest, correct way to get a working Python dev setup on this version of Ubuntu — any clarification appreciated.