# 需要最新的pip 来安装 tensorflow 2
pip install --upgrade pip
Collecting pip Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 9.0.1 Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr Successfully installed pip-19.3.1
# 在次检测pip版本号
pip -V
# 光机一下就报错了
Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> from pip import main ImportError: cannot import name main root@zjwlgr-virtual-machine:/home/zjwlgr# pip 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())
如果报如下错误
Traceback (most recent call last): File "/usr/bin/pip3", line 11, in sys.exit(main()) File "/usr/lib/python3/dist-packages/pip/__init__.py", line 215, in main locale.setlocale(locale.LC_ALL, '') File "/usr/lib/python3.5/locale.py", line 594, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting
在Linux终端输入以下命令即可
export LC_ALL=C