ModuleNotFoundError: 没有名为“distutils.core"的模块 [英] ModuleNotFoundError: No module named 'distutils.core'

查看:53
本文介绍了ModuleNotFoundError: 没有名为“distutils.core"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从 Ubuntu 18.04 升级到了 python 3.719.04.但我使用 Python 3.6 处理了许多项目.

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

ModuleNotFoundError: 没有名为distutils.core"的模块

我不知道该怎么办.

我尝试安装 distutils:

milano@milano-PC:~$ sudo apt-get install python3-distutils阅读包裹清单...完成构建依赖树读取状态信息...完成python3-distutils 已经是最新版本 (3.7.3-1ubuntu1).0 升级,0 新安装,0 删除,0 未升级.

但是正如你所看到的,我有最新版本.

你知道该怎么做吗?

解决方案

Python 基础解释器确实需要一些额外的模块.那些没有安装,例如默认为 Ubuntu 18.04.

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

# 从你的项目解释器运行# your_project_python --version$ python3 --version蟒蛇 3.7.8

您现在需要为这个精确的 Python 解释器安装 distutils.因此,此示例的解决方案是:

sudo apt install python3.7-distutils# sudo apt install python3-distutils # 只会更新默认的 python intrpreter

请记住,仅从任何命令行运行 python 可能是其他版本的 python,然后您在您的项目中运行!

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

$ which python/usr/bin/python$ ls -lach/usr/bin/pythonlrwxrwxrwx 1 root root 9 Jun 8 2018/usr/bin/python ->蟒蛇2.7

原始来源:参考这篇文章

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

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'

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?

解决方案

Python base interpreter does require some additional modules. Those are not installed with e.g. Ubuntu 18.04 as default.

To solve this we need to first find the python version you're running. If you have only installed one python version on your system (and you are sure about it) you can skip this step.

# from your project interpreter run
# your_project_python --version
$ python3 --version
Python 3.7.8

You now need to install for this precise python interpreter the distutils. So here the solution for this example would be:

sudo apt install python3.7-distutils
# sudo apt install python3-distutils  # would just update default python intrpreter

Keep in mind, that just running python from any command line might be an other version of python then you're running in your project!

If this hasn't helped, look for the following possibilities. This will bring you the binary which resolved from the alias in the command line.

$ which python
/usr/bin/python
$ ls -lach /usr/bin/python
lrwxrwxrwx 1 root root 9 Jun  8  2018 /usr/bin/python -> python2.7

original source: refer to this article

For this answer I've also merged, summarized, ordered and explained some of the content which has been provided by Neo, Andrei, Mostafa and Wolfgang.

这篇关于ModuleNotFoundError: 没有名为“distutils.core"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆