ModuleNotFoundError: No module named 'distutils.core'

Milano picture Milano · Apr 18, 2019 · Viewed 59.5k times · Source

I've recently upgraded from Ubuntu 18.04 to 19.04 which has python 3.7. But I work on many projects using Python 3.6.

Now when I try to create a virtualenv with Python 36 in PyCharm, it raises:

ModuleNotFoundError: No module named 'distutils.core'

enter image description here

I can't figure out what to do.

I tried to install distutils:

milano@milano-PC:~$ sudo apt-get install python3-distutils
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-distutils is already the newest version (3.7.3-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

But as you can see I have the newest version.

Do you know what to do?

Answer

Cutton Eye picture Cutton Eye · Apr 22, 2019

Python base interpreter does require some additiional modules. Those are not installed with 18.04 as default. To solve the missing packages problem run the following and restart pycharm afterwards

sudo apt-get install python3-distutils

refer to this article