$ sudo -H python get-pip.py --prefix /usr DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting pip Downloading https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl (1.4MB) |████████████████████████████████| 1.4MB 1.1MB/s Installing collected packages: pip Successfully installed pip-19.2.3
1 2 3 4 5 6 7
$ which pip /usr/bin/pip $ pip --version Traceback (most recent call last): File "/usr/bin/pip", line 6, in <module> from pip._internal import main ImportError: No module named pip._internal
$ ls /usr/lib/python2.7/site-packages/ pip pip-19.2.3.dist-info $ ls /usr/lib/python2.7/dist-packages/ | grep pip
解决办法
两种方式:
添加 site-package 目录
1 2
$ echo'/usr/lib/python2.7/site-packages/' | sudo tee /usr/lib/python2.7/dist-packages/xxx.pth /usr/lib/python2.7/site-packages/
1 2 3 4
$ which pip /usr/bin/pip $ pip --version pip 19.2.3 from /usr/lib/python2.7/site-packages/pip (python 2.7)
将 pip 安装至用户目录
严格来说,这不是解决办法,而是一种规避手段:
1 2 3 4 5 6
$ python get-pip.py --user DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting pip Using cached https://files.pythonhosted.org/packages/30/db/9e38760b32e3e7f40cce46dd5fb107b8c73840df38f0046d8e6514e675a1/pip-19.2.3-py2.py3-none-any.whl Installing collected packages: pip Successfully installed pip-19.2.3
1 2 3 4
$ which pip /home/runsisi/.local/bin/pip $ pip --version pip 19.2.3 from /home/runsisi/.local/lib/python2.7/site-packages/pip (python 2.7)
1 2 3 4 5
$ pip install ipython --user DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting ipython Using cached https://files.pythonhosted.org/packages/b0/88/d996ab8be22cea1eaa18baee3678a11265e18cf09974728d683c51102148/ipython-5.8.0-py2-none-any.whl ...
参考资料
What’s the difference between dist-packages and site-packages?