can't install pip anymore with python 2.7?

colorf picture colorf · Jan 4, 2021 · Viewed 7.2k times · Source

I wanted to use a python script compatible with python 2.7 (but not 3.8)

I need pip to make the script work but looks like I can't install pip anymore ? I tried with get-pip.py , but it's not working :

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

Answer

Alex Punnen picture Alex Punnen · Jan 27, 2021

The latest pip has dropped support for Python 2 And you cannot install the latest pip via get-pip.py using Python 2.7.

Update: Found an answer here with the script for 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. Note - it installs an older version of Pip that that comes from above script.

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-tools/

# 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)