Upgraded to ubuntu 20 LTS from 18 LTS -- pycharm can't find distutils

I've tried installing distutils in the pycharm terminal, then re-installing pip.

 

pip3 --version 

give a sensible output, but whenever I try to create a new project, I get 

an error related to being unable to install an interpretor, and being unable to find module 'distutils.util'

From a normal ubuntu terminal, 

pip3 --version 

also gives a sensible output.

 

Ideas? I'm lost after spending hours on this.

 

 

0
4 comments

Normally you need to install distutils using OS package manager. E.g. see https://stackoverflow.com/questions/3810521/how-to-install-python-distutils

Make sure you can `import distutils` for your interpreter before trying to setup it in PyCharm.

1

Actually it is already installed.

 

Some more information:

 

On an Ubuntu 20 LTS system (Ubuntu 20.04.1 LTS), just upgraded from 18.04 LTS
and running Pycharm 2020.2.3 professional (re-installed several times since upgrade of Ubuntu, via snap).

Checking that I have distutils installed:
sudo apt-get reinstall python3-distutils

Gives the following output:

Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 1 to reinstall, 0 to remove and 11 not to upgrade.
Need to get 0 B/141 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 397429 files and directories currently installed.)
Preparing to unpack .../python3-distutils_3.8.5-1~20.04.1_all.deb ...
Unpacking python3-distutils (3.8.5-1~20.04.1) over (3.8.5-1~20.04.1) ...
Setting up python3-distutils (3.8.5-1~20.04.1) ...

 

At the bash command line:
pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

 

Within pycharm, creating a new project
executes the following command:
/snap/pycharm-professional/218/plugins/python/helpers/pip-20.1.1-py2.py3-none-any.whl/pip install --no-index /snap/pycharm-professional/218/plugins/python/helpers/setuptools-44.1.1-py2.py3-none-any.whl

This fails, indicating that the it "Failed to create interpreter"
giving the following output...
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/snap/pycharm-professional/218/plugins/python/helpers/pip-20.1.1-py2.py3-none-any.whl/pip/__main__.py", line 23, in <module>
File "/snap/pycharm-professional/218/plugins/python/helpers/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/main.py", line 10, in <module>
File "/snap/pycharm-professional/218/plugins/python/helpers/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/autocompletion.py", line 9, in <module>
File "/snap/pycharm-professional/218/plugins/python/helpers/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/main_parser.py", line 7, in <module>
File "/snap/pycharm-professional/218/plugins/python/helpers/pip-20.1.1-py2.py3-none-any.whl/pip/_internal/cli/cmdoptions.py", line 19, in <module>
ModuleNotFoundError: No module named 'distutils.util'


I tried installing a new VENV and assigned a different interpretor to it (the system python3.8) and got it to work, but lost all my libs and modules. 

I could not get it to work otherwise.

 

0

Well, there's no guarantee it was properly installed until you can import it.

What is the path to interpreter that you tried to configure? Please run this interpreter shell in the terminal and try to `import distutils`. Does it work?

0
Avatar
Permanently deleted user

I had the same problem. I am very new to pycharm but my interpretation is, that during the update of ubuntu python was also updated. So you venv has a reference to a python version where some packages are removed. You should create a new venv envirment with the actual python3.8. This worked for me.

0

Please sign in to leave a comment.