简体   繁体   English

升级到pip版本18.1后,pip3命令失败

[英]pip3 command fails after upgrading to pip version 18.1

After upgrading pip3 using $ pip3 install --upgrade pip , pip3 fails to work. 使用$ pip3 install --upgrade pip --upgrade $ pip3 install --upgrade pip升级pip3后,pip3无法正常工作。 And throws this: Error Command: 并抛出此:错误命令:

Traceback (most recent call last):
      File "/usr/bin/pip3", line 9, in <module>
        from pip import main
    ImportError: cannot import name 'main'

it's having the same issue again even after removing the pip3 and reinstalling it. 即使删除pip3并重新安装它,它仍然再次遇到相同的问题。

Somewhere someone suggested to change the from pip import main to from pip._internal import main . 有人建议将from pip import main更改from pip._internal import main But still it didn't work. 但是仍然没有用。

As a general rule, it's best to leave your OS's Python installation alone, as it can be used for system dependencies. 通常,最好不要安装操作系统的Python安装,因为它可以用于系统依赖性。 Install a clean version of Python with pyenv , and/or use virtualenv / Pipenv for development. 使用pyenv安装Python的干净版本,和/或使用virtualenv / Pipenv进行开发。

The pip3 command in the stack trace is in the system's binary path, and thus was probably installed by your operating system's package manager. 堆栈跟踪中的pip3命令位于系统的二进制路径中,因此可能是由操作系统的程序包管理器安装的。 It will be expecting an older version of pip, which you've removed by upgrading it. 它将期望使用较旧版本的pip,您已通过升级将其删除。

As a temporary workaround, try running /usr/local/bin/pip3 . 作为临时的解决方法,请尝试运行/usr/local/bin/pip3

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

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