简体   繁体   English

无法使用pip3安装软件包

[英]Unable to use pip3 to install packages

Hey guys I think my pip3 has just hit a snag. 大家好,我认为我的pip3遇到了障碍。 Can somebody help me with this. 有人可以帮我这个忙吗? I ran this command: 我运行了以下命令:

pip3 install tensorflow

And it gave this as an output: This output is not only with tensorflow package but with any package i try to install with pip3. 它作为输出提供:此输出不仅与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'

What can be the reason Edit: pip works just fine but pip3 doesn't work 可能是什么原因?编辑:pip正常但pip3无效

Try update pip and setuptools 尝试更新pip和setuptools

pip3 install --upgrade pip setuptools

Also, the best way is using virtualenv 另外,最好的方法是使用virtualenv

You are using the wrong syntax. 您使用了错误的语法。 Just try pip install tensorflow in command prompt and everything should run smoothly. 只需在命令提示符下尝试pip install tensorflow ,一切都应该可以平稳运行。 I tried at my end and it worked. 我尽力而为,并成功了。 Refer attached image. 请参考附件图像。 See the first few lines and the last few lines. 请参阅前几行和后几​​行。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM