[英]can't install pip anymore with python 2.7?
我想使用與 python 2.7(但不是 3.8)兼容的 python 腳本
我需要 pip 才能使腳本正常工作,但看起來我不能再安裝 pip 了? 我嘗試使用 get-pip.py,但它不起作用:
user@DESKTOP-J9T7UBF
$ get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
c:\users\user\appdata\local\temp\tmp2kztqk\pip.zip\pip\_vendor\urllib3\util\ssl_.py:387: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
The latest pip has dropped support for Python 2 And you cannot install the latest pip via get-pip.py using Python 2.7.
更新:在 Python 2.7 https://stackoverflow.com/a/65866547/429476的腳本中找到了答案。
You should upgrade to Python 3. You can use your Linux package manager if you using a Linux distro which have only Python2.7. 注意 - 它安裝了來自上述腳本的舊版本 Pip。
If you installed Python from a package manager on Linux, you should always install pip for that Python installation using the same source. https://pip.pypa.io/en/stable/installing/ --> https://packaging.python.org/guides/installing-using-linux
# curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1883k 100 1883k 0 0 6584k 0 --:--:-- --:--:-- --:--:-- 6584k
# python get-pip.py --user
Traceback (most recent call last):
File "get-pip.py", line 24226, in <module>
main()
File "get-pip.py", line 199, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
from pip._internal.cli.main import main as pip_entry_point
File "/tmp/tmpyG_UJ3/pip.zip/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
# sudo apt-get install python-pip
# python -m pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
pip install --upgrade "pip < 21.0"
已安裝 python2
安裝了python3(是3)
將舊版 pip 安裝到 python3(例如 9): python3 -m pip install --upgrade "pip==9"
找到它的安裝位置: python3 -m pip show pip
復制到python2的PATH:
sudo cp -r /home/usr/.local/lib/python3.8/site-packages/pip-9.0.0.dist-info/ /usr/local/lib/python2.7/dist-packages/
sudo cp -r /home/raczb/.local/lib/python3.8/site-packages/pip /usr/local/lib/python2.7/dist-packages/
檢查: python2.7 -m pip --version
重新升級python3的pip。
問題似乎是沒有指定pip
的特定版本,因此,腳本正在嘗試安裝最新版本(21 或更高版本)。 嘗試指定舊版本,例如
python get-pip.py 'pip==20.3.1'
此腳本是否僅與 Python 2.7 兼容? 嘗試將腳本更新為非棄用版本,然后運行它。
Open the Python 2.7 installer, go to Advanced options and look for an 'Install pip
' checkmark, since in the later releases of Python did come with an 'Install pip
' checkmark, in Advanced options.
嘗試通過手動方法獲取模塊,即查看所需模塊的網站並安裝到C:\Python27\Scripts
。
如果以上解決方案都沒有幫助,我建議您參考這篇文章。 我會通知您,自 2020 年 1 月 1 日起,Python 2.7 被視為已棄用。
是的 pip 已放棄對 python 2.7 的支持。 如果您仍想將它用於 python 2.7,降級 pip 將幫助您:
sudo easy_install pip==20.3.4
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.