Leif160519的blog Leif160519的blog

——————

目录
升级pip后出现ImportError: cannot import name main
/    

升级pip后出现ImportError: cannot import name main

在Ubuntu中,升级了pip,再次使用pip 安装相关的python包的时候就出现以下错误

ImportError: cannot import name main

解决:pip文件在/usr/bin目录下,cd进去,进行以下修改

把下面的三行

from pip import main
if __name__ == '__main__':
    sys.exit(main())

换成下面的三行

from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

然后问题就解决了。

如果在pip时候遇到权限问题,如下错误,此时可以直接加sudo进行解决,sudo pip install ....

如果遇到超时问题或者下载很慢的问题,可以给pip换源,具体参看:https://github.icu/articles/2019/08/22/1566462724733.html


“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题升级pip后出现ImportError: cannot import name main
作  者Leif160519
出  处https://github.icu/articles/2019/08/30/1567132801052.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!