本文主要是介绍pip3升级时遇到的一些错误,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用
sudo pip3 install --upgrade pip
更新pip3到最新时候
1、遇到如下错误。
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
解决:
参考:https://www.cnblogs.com/z-x-y/p/9668505.html
将
from pip import main
if __name__ == '__main__':sys.exit(main())
替换为
from pip import __main__
if __name__ == '__main__':sys.exit(__main__._main())
2、一些警告
WARNING: The directory '/home/s/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/s/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
参考:http://blog.sina.com.cn/s/blog_a046022d0102w2ux.html
解决:
如果必须用sudo pip,更改pip目录属主即可
sudo chown root /home/s/.cache/pip/http
sudo chown root /home/s/.cache/pip
这篇关于pip3升级时遇到的一些错误的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!