Python ModuleNotFoundError:没有名为';distutils.core';

Python ModuleNotFoundError:没有名为';distutils.core';,python,pycharm,virtualenv,python-3.6,Python,Pycharm,Virtualenv,Python 3.6,我最近从ubuntu18.04升级到19.04,它有python3.7。但是我使用python3.6处理许多项目 现在,当我尝试在PyCharm中使用Python36创建virtualenv时,它会引发: ModuleNotFoundError: No module named 'distutils.core' 我不知道该怎么办 我尝试安装distutils: milano@milano-PC:~$ sudo apt-get install python3-distutils Reading

我最近从
ubuntu18.04
升级到
19.04
,它有
python3.7
。但是我使用
python3.6
处理许多项目

现在,当我尝试在PyCharm中使用
Python36
创建
virtualenv
时,它会引发:

ModuleNotFoundError: No module named 'distutils.core'

我不知道该怎么办

我尝试安装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.
但正如你所看到的,我有最新的版本


您知道该怎么做吗?

Python基本解释器确实需要一些额外的模块。默认情况下未安装Ubuntu 18.04等

为了解决这个问题,我们需要首先找到您正在运行的python版本。如果您的系统上只安装了一个python版本(并且您对此很确定),则可以跳过此步骤

# from your project interpreter run
# your_project_python --version
$ python3 --version
Python 3.7.8
现在需要为这个精确的python解释器安装distutils。 因此,本例的解决方案是:

sudo apt install python3.7-distutils
# sudo apt install python3-distutils  # would just update default python intrpreter
请记住,从任何命令行运行python可能是python的另一个版本,然后您就可以在项目中运行了

如果这没有帮助,请寻找以下可能性。这将为您带来从命令行中的别名解析的二进制文件

原始资料来源:


对于这个答案,我还对Neo、Andrei、Mostafa和Wolfgang提供的一些内容进行了合并、总结、排序和解释。

其他案例

这发生在我的python3.7安装上,但不是在我将ubuntu升级到20.04之后的主python3上

:


如果我在Ubuntu20.04上有多个版本的python3(ETC3.8为主版本,ppa:deadsnakes/ppa中有3.9版本)(在我的例子中是Kubuntu20.04)并且它不工作

sudo apt install python3-distutils
然后它对我有效

sudo apt install python3.9-distutils

对我来说,这个问题是通过专门使用python3解决的,因此确保使用python3.8

python——版本
Python 3.7.5
python3——版本
Python 3.8.5

目前,我正在使用
ubuntu18.04
python3.6.9
。运行以下命令后,我的问题得到解决:


更多详细信息:python中需要一些未安装的模块。

看看这两个模块是否有帮助:或者我还必须安装setuptools和pip才能使其正常工作:
sudo-apt-get-install-python3-pip
sudo-apt-get-install-python3-setuptools
在我的情况下,不需要重新启动。安装apt后工作良好…这是Andrei说的。您只为一个软件包安装了dist utils。HintStutils的thx可能是python3开发的一个子集?我假设(未经测试),python的开发包包含的数据比distutils多得多。纯代码未编译库等。简而言之,distutils更精确。Dev可能包含更多的开销。@CuttonEye我也尝试过distutils,但仍然不能正常工作。你是对的!
sudo apt install python3-distutils
sudo apt install python3.9-distutils
sudo apt-get install python3-dev