使用pip安装模块失败

时间:2019-02-21 11:25:13

标签: pip python-3.6

我正在尝试使用pip3安装numpy。 这是我使用的命令:

pip3 install numpy(也尝试了sudo,但给出了相同的错误)

但是出现以下错误:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.distro'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 11, in <module>
    load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 21, in <module>
    from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 67, in <module>
    vendored("distro")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 1051, in <module>
  File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 595, in __init__
  File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 932, in _get_lsb_release_info
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1

这是我尝试安装任何Python模块时的问题 直到几天前,它的工作情况都还不错。

我尝试完全删除pip,然后重新安装。但是我得到了同样的错误 现在没有任何软件包可以通过pip安装。

我有python 3.6.5

如何解决此问题?

2 个答案:

答案 0 :(得分:1)

我也有这个问题。 我通过安装anaconda并安装了所有ml软件包来解决了该问题

答案 1 :(得分:0)

在将系统默认设置为Python3.5后,我遇到了这个问题。奇怪的是,似乎pip3需要Python2.7才能运行;运行# update-alternatives --config python并选择Python2.7使pip3为我再次工作。我刚刚以这种方式安装了pygame,并且在将系统默认值切换回Python3.5之后,它可以按预期工作。这是基于Devuan ASCII和

$ python --version
Python 3.5.3
$ pip3 --version 
...
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1

$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/python3.5   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
* 2            /usr/bin/python3.5   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 1

$ python --version
Python 2.7.13
$ pip3 --version 
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)

编辑:在Raspbian Stretch pip3上,Python3.5作为系统默认设置,因此,这显然不是全部内容:

$ python --version
Python 3.5.3
$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)