0

TLDR: There are two version of Python on my system. The older version can't access distutils.

I am running a fresh install of Ubuntu 22.04.
The distro comes with two versions of python already installed: Python 3.10 & Python 3.9 and no instances of pip.

I've installed pip by running:

sudo apt install python3-pip

That makes pip available for Python 3.10. I can confirm that by:

$ python3.10 -m pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)

However, pip is not working for Python 3.9. See:

$ python3.9 -m pip --version
Traceback (most recent call last):
...
from distutils.cmd import Command as DistutilsCommand

ModuleNotFoundError: No module named 'distutils.cmd'

python3-distutils is installed (v 3.10 only):

$ apt list --installed | grep distutils
python3-distutils/jammy-updates,jammy-updates,now 3.10.6-1~22.04 all [installed]

I can't install python3-distutils version 3.9:

$ sudo apt install python3.9-distutils
E: Unable to locate package python3.9-distutils
E: Couldn't find any package by glob 'python3.9-distutils'

Question How to make distutils available for Python 3.9 so pip works with the version of Python.

Jake
  • 1
  • "Question How to make distutils available for Python 3.9 so pip works with the version of Python." ... Answer: create a virtual environment https://askubuntu.com/a/1348136/968501 – Raffa Mar 02 '23 at 18:28
  • 2
    Does this answer your question? [How to install latest version of python 3.9.5 on Ubuntu 20.04?](https://askubuntu.com/questions/1347748/how-to-install-latest-version-of-python-3-9-5-on-ubuntu-20-04) – karel Mar 03 '23 at 11:09

0 Answers0