使用
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