0%

Ubuntu16下 pip安装,卸载、升级,报错

新装的ubuntu16,自带的python2.7,使用pip升级后,报错,修改记录如下:

如何彻底卸载pip?

sudo python -m pip uninstall pip

如何安装pip

sudo apt install python-pip

如何安装指定版本的pip

python -m pip install pip==18.1(换成你想要的版本编号)

pip安装软件过程中报错:

Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-BqMhb7/matplotlib/

  1. 安装并升级setuptools
    pip install –upgrade setuptools
  2. 升级pip
    pip install –upgrade pip

pip升级后报错

1
2
3
4
5
6
7
8
9
10
11
12
13
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
修改/usr/bin/pip如下:
//修改前
from pip import main
if __name__ == '__main__':
sys.exit(main())
修改后
from pip import __main__ //这行也要修改
if __name__ == '__main__':
sys.exit(__main__._main())//增加__main__._ (注意最后main()前面有个_)