6

After upgrading to Ubuntu 20.04 I started receiving this error

ModuleNotFoundError: No module named 'distutils.util' for every pip command I run.

I tried the solutions on ModuleNotFoundError: No module named 'distutils.util' and pip3 is pointing to the wrong version of python but nothing seems to be working.

Tried this:

python3 -m pip

and:

sudo apt-get install python3-distutils
sudo apt-get install python3-apt

these two commands are telling me these packages are already installed, so I reintalled them but no light at the end of the tunnel.

Any solution for this?

I have a virtual environment running Python 3.6.9.

assembler
  • 169
  • 1
  • 1
  • 7

4 Answers4

10

In my case, I solved this with

sudo apt install python3.10-distutils
Gabriel Raby
  • 101
  • 1
  • 3
1

I fixed this by installing the version-specific distutils:

i.e.:

sudo apt install python3.9-apt
1

You can try solving it by installing your version of distutils, as you are running Python 3.6.9:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt install python3.6-distutils
user2298922
  • 21
  • 1
  • 3
  • I'd note that you need to trust the source of the ppa as you'll be giving them sudo access on install. Bionic has [distutils](https://packages.ubuntu.com/search?suite=default&section=all&arch=any&keywords=python3-distutils&searchon=names) 3.6.9, which may be better than using a random ppa. – pbhj Jul 13 '22 at 19:01
0

I solved this by creating a new virtual environment running Python 3.8.

Stanko
  • 446
  • 4
  • 6