67

When I try to add virtualenv as an interpreter in PyCharm Community 2018.1.2 in Kubuntu 18.04 I get the following error:

ModuleNotFoundError: No module named 'distutils.core'

enter image description here

How can I solve this?

Hrvoje T
  • 1,949
  • 3
  • 18
  • 28

7 Answers7

97

I had to install it. This was fresh Kubuntu 18.04 install, obviously, without this needed package.

sudo apt-get install python3-distutils

After that I restarted PyCharm and creating virtual project interpreter was successful.

Hrvoje T
  • 1,949
  • 3
  • 18
  • 28
  • To bad the question doesn't specify *how* pycharm has been installed. So just for the completness sake: 1. This Pycharm has *probably* been installed with snap. (I use pycharm on several installs on a daily basis and never had this error. Only after testing snap with pycharm on a new 18.04 install) 2. After installing 'python3-disutils'. I received the error "ModuleNotFoundError: No module named 'setuptools'". – MadMike Oct 16 '18 at 05:42
  • This will not install setup-tools. But `python3-pip` does. – wowkin2 Jul 10 '19 at 07:49
  • @MadMike In my case, the issue was a windows install attempting to use the remote SSH interpreter while targeting a raspbian server. Simply installing distutils as shown above was sufficient to get the interpreter going. – Basic Jul 15 '19 at 20:57
  • I cannot install `python3-pip`, please see https://askubuntu.com/questions/1185084/ubuntu-oracle-jdk-issues-but-version-looks-okay – mLstudent33 Oct 30 '19 at 21:03
  • PyCharm from snap: It got me past that error. Then I got to install setuptools. – Gunslinger Nov 27 '19 at 08:08
  • after running this command I get `python3-distutils is already the newest version (3.8.2-1ubuntu1).` but getting the same error, can someone help me. – Sarthak Kumar May 05 '20 at 11:23
7

If @Hrvoje T's answer did not work (it did not work for me) then try this:

Run this command and you should be able to install the packaging tools in Pycharm:

sudo apt install python3-pip

It's python3-pip, not python-pip if you are using the Python3 interpreter.

https://stackoverflow.com/questions/43567996/pycharm-python-packaging-tools-not-found

Blackwood
  • 3,123
  • 11
  • 23
  • 32
hyukkyulee
  • 171
  • 1
  • 3
2

Neither @Hrvoje T and @hyukkyulee worked for me since I had already installed those packages. Uninstalling and reinstalling didn't solve the issue as well.

I just upgraded my system to Ubuntu 19.10 and I noticed that they had upgrade the python interpreter to 3.7. PyCharm however was generating the venv interpreter based to its previous one (python 3.6). By changing the base interpreter from New Interpreter block I solved this issue.

Koldar
  • 121
  • 4
0

Actually, @hyukkyulee solution solved the issue.

It is because, by default, Ubuntu comes with python 2.7 and python 3.x version. And if you have installed pip using

sudo apt install python-pip

will install 'pip' in python 2.7 folder.

so you need to specify python3-pip to install pip in python 3 folder along with other util packages.

SangyK
  • 111
  • 4
0

Had the same issue with an installation of: PyCharm 2019.3.2 (Edu) Build #PE-193.6494.27, built on February 5, 2020 Runtime version: 11.0.5+10-b520.38 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o Linux 5.3.0-7629-generic

Installed on Pop!_OS 19.10 with Python 3.7.2 installed. I did use Jetbrains Toolbox to install pycharm edu. Jetbrains Toolbox was installed using a script suggested by jetbrain's pycharm download page.

Running: sudo apt install python3-pip

solved the problem instantly, didn't even have to restart pycharm, just created a new project and no issue setting up the virtual environment.

I did install python-pip after updating to python 3.7.2 before having pychram installed. So same as running python3.7 in a terminal without changing the alias the 3 after python matters.

0

For me, PyCharm was trying to select Python 3.7 in the project creation wizard, but my base Ubuntu system was using Python 3.8 and distutils was installed for Python 3.8.

Solution was to select Python 3.8 as my base interpreter in the project wizard. enter image description here

Daniel
  • 303
  • 1
  • 3
  • 6
0

Python on Chromebook, Atom -> if you are having issues, then follow the suggestion above:

Running:

sudo apt install python3-pip.

Then you can install ipykernel by running:

python -m ipykernel install --user

Aulis Ronkainen
  • 2,612
  • 42
  • 29
  • 27
  • Avoid posting answers to old questions that already have well received answers unless you have something substantial and new to add. – Toto Oct 03 '22 at 08:02