3

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

4

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,431
  • 9
  • 52
  • 78
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.

  • Never ever install another python version. Python is an integral part of Ubuntu See here for more infos. Using pipenv or others environments is fine – kanehekili Dec 08 '22 at 22:53
  • 1
    You are right and I didn't. As I wrote: "I update Ubuntu 20.04 to 22.04" I always uses venv and I do every change in the virtual environment that requires changes. What solved the problem was updating the virtual environment. – Angelo Mascaro Dec 09 '22 at 11:03
  • Ah, nice catch. Thanks for sharing. – kanehekili Dec 09 '22 at 14:00