Python 导入错误:没有名为 extern 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35446765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 16:27:30  来源:igfitidea点击:

ImportError: No module named extern

pythonpython-2.7pipsetuptoolsimporterror

提问by Aleph Melo

I'm getting this error when trying to install any package with pip. I have two pip instances, one with Python 2.7 and other with Python 3.

尝试使用 pip 安装任何软件包时出现此错误。我有两个 pip 实例,一个使用 Python 2.7,另一个使用 Python 3。

    Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 375, in setup_py
    import setuptools  # noqa
  File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 11, in <module>
    from setuptools.extern.six.moves import filterfalse, map
  File "/usr/local/lib/python2.7/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
    from pkg_resources.extern import VendorImporter
ImportError: No module named extern

Even when I try to install the 'extern' module I get this error. Also when installing with Python itself, like python setup.py install.

即使当我尝试安装“extern”模块时,我也会收到此错误。同样在使用 Python 本身安装时,例如python setup.py install.

Thanks in advance.

提前致谢。

采纳答案by Vinod

sudo apt-get purge python-pkg-resources
sudo apt-get -f install

here actually packages are removed and purged (any configuration files are deleted too).

这里实际上包被删除和清除(任何配置文件也被删除)。

-f : Attempt to correct a system with broken dependencies in place.

-f :尝试更正具有损坏依赖关系的系统。

sudo pip install packagename

sudo pip install packagename

#sourcehere

#sourcehere

回答by Kjjassy

Not sure whether it is installation issue or packege but it seems like you will not be able to import any package of them, if you have installed python perfectly then

不确定是安装问题还是packege,但如果您已经完美安装了python,那么您似乎无法导入其中的任何包

try this commands

试试这个命令

step 1 :

第1步 :

$which pip
/usr/local/bin/pip

step 2 :

第2步 :

/usr/local/bin/pip install django

or any of your package name. I am considering ubuntu(OS)

或您的任何包名称。我正在考虑 ubuntu(OS)

回答by gab7

You can try the following command; it has worked for me:

你可以试试下面的命令;它对我有用:

sudo apt-get install --reinstall python-setuptools

回答by saurabh

Do this it will work

这样做它会起作用

sudo pip install -U setuptools 

回答by RGuth

I know this is an old thread, but I just wanted to contribute since I ran into this issue and this thread kept coming up in the results.

我知道这是一个旧线程,但我只是想贡献,因为我遇到了这个问题并且这个线程不断出现在结果中。

Note: This was on MacOS 10.12. My shell is zsh and I already have brew installed

注意:这是在 MacOS 10.12 上。我的 shell 是 zsh 并且我已经安装了 brew

First I ran each of these commands

首先我运行了这些命令中的每一个

brew install python
brew install python3

This will either install it or you'll receive an "already installed" message as I did.

这将安装它,或者您会像我一样收到“已安装”消息。

Next, run the following command

接下来,运行以下命令

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

And last:

最后:

sudo python?get-pip.py

Final note: for my install to work, I ended up having to run the command with pip3

最后一点:为了我的安装工作,我最终不得不使用 pip3 运行命令

sudo pip3 install nameofinstallhere