无法使用pip3来安装软件包

时间:2018-02-03 16:03:05

标签: python pip

嘿伙计们,我认为我的pip3刚刚遇到障碍。有人可以帮我这个。 我运行了这个命令:

pip3 install tensorflow

它将此作为输出: 此输出不仅包含tensorflow包,而且还包含我尝试使用pip3安装的任何包。

   Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/home/het/.local/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/home/het/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
    from pip._vendor import pkg_resources
  File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
    @_call_aside
  File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
    f(*args, **kwargs)
  File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
    dist.activate(replace=False)
  File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
    declare_namespace(pkg)
  File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
    _rebuild_mod_path(path, packageName, module)
  File "/home/het/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2121, in _rebuild_mod_path
    orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'

可能是什么原因 编辑:pip工作正常,但pip3不起作用

2 个答案:

答案 0 :(得分:0)

尝试更新pip和setuptools

pip3 install --upgrade pip setuptools

此外,最好的方法是使用virtualenv

答案 1 :(得分:0)

您使用的语法错误。只需在命令提示符下尝试pip install tensorflow,一切都应该顺利进行。我尝试了我的结果并且有效。参考附图。请参阅前几行和最后几行。enter image description here