4

I update Ubuntu 20.4 to 22.4 and after that pip is no longer working in the virtual environments based on python 3.9 and this is the error I get:

ModuleNotFoundError: No module named 'distutils.cmd'

What I understood from my searches is that the missing module was in Python3.8 and they suggested to install the module

sudo apt install python3.8-distutils

I did it and got this error:

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

Package python3.8-distutils is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from Another source

E: Package 'python3.8-distutils' has no installation candidate

I have no idea what to do.

2 Answers2

7

I got the same error when setting up a project that is expecting Python 3.8 on Ubuntu 22.04. Since I had installed Python 3.8 using the deadsnakes PPA already, simply issuing

sudo apt install python3.8-distutils

solved the problem for me.

Melebius
  • 11,750
1

Eventually I decided to try to turn around the problem. I created a backup of my virtual environment then I updated it to python3.10 because with this version pip worked properly.

python3.10 -m venv --upgrade my-env

this solution apparently works well.