can't install pip anymore with python 2.7?
Asked Answered
O

9

19

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
Onagraceous answered 4/1, 2021 at 5:28 Comment(6)
Python 2.x closed and have no longer support and continuetion from January 1, 2021Chromomere
yeah I know , but there is no way to keep using scripts compatible only with 2.7?Onagraceous
Is that really all the output? The last line is a warning, not an error.Finale
you can downgrade your pip and install the packages in that mannerOverdrive
It's better to switch to Python 3. Try docs.python.org/3/library/2to3.html to convert.Denouement
You should download a pip version compatible with python2.7: curl bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.pyInsalivate
B
16
pip install --upgrade "pip < 21.0"
Bethelbethena answered 16/3, 2021 at 7:3 Comment(2)
This should be accepted answerEjecta
why should it be accepted? If you don't already have pip installed, you cannot possibly ask pip to upgrade itselfBueno
T
8

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://mcmap.net/q/95108/-pip-install-failing-on-python2-duplicate.


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)
Thrash answered 27/1, 2021 at 4:1 Comment(0)
G
4

Yeah pip has dropped it's support to python 2.7. If you still want to use it for python 2.7, downgrading the pip will help you:

sudo easy_install pip==20.3.4
Gurias answered 25/8, 2021 at 13:8 Comment(0)
S
3

A working solution:

  1. Have an installed python2

  2. Have an installed python3 (yes 3)

  3. Install a legacy pip to python3 (eg 9): python3 -m pip install --upgrade "pip==9"

  4. Find where it has been installed to: python3 -m pip show pip

  5. Copy to python2's 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/

  6. Check: python2.7 -m pip --version

  7. Re-upgrade python3's pip.

Saiz answered 2/8, 2021 at 11:17 Comment(0)
U
3

An other working solution based on get-pip.py that doesn't downgrade python3 pip version:

curl 'https://raw.githubusercontent.com/pypa/get-pip/20.3.4/get-pip.py' -o get-pip.py
python2 get-pip.py

Explanation: pip 21.0 has dropped support for Python 2.7 in January 2021

Ussery answered 14/3, 2022 at 16:4 Comment(0)
N
3

PIP can install in python2.7 using this below command

python2.7 -m ensurepip --default-pip
Noles answered 15/3, 2023 at 9:57 Comment(0)
U
0

The problem seems to be that no specific version of pip was specified, and therefore, the script is trying to install the latest version (21 or later). Try specifying an older version, e.g.

python get-pip.py 'pip==20.3.1'

Documented: https://github.com/pypa/get-pip

Unmoving answered 4/1, 2021 at 5:49 Comment(2)
Thanks for your answer I tried to specify an older version but I got "ERROR: Invalid requirement: "'pip==20.3.1'" (I tried differents versions)Onagraceous
Try specifying a specific python to run with, e.g. python2.7 get-pip.pyUnmoving
A
0
  1. Is this script only compatible with Python 2.7? Try to update the script to a non-deprecated version, then run it.

  2. 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.

  3. Try attaining the module by manual methods i.e Look on the website of the desired module and install to C:\Python27\Scripts.

If none of the above solutions are of assistance, I suggest you consult this article. I will inform you that Python 2.7 was considered as deprecated as of January 1st, 2020.

Autrey answered 4/1, 2021 at 6:19 Comment(0)
H
0

As of today, you can no longer install or downgrade pip from the installer itself. Solution:

Step 1: If you have a working older version of python make a list of all modules that you have or need (this will come in handy in future projects if you move to another computer).

Step 2: Download and unzip setuptools-44.1.1 (because pip needs it) and install it using Powershell with admin privileges going to the location of the setup.py file. Use the following command:

py -2.7 setup.py install

Step 3: Download and unzip pip-20.3.4; and repeat Powershell procedure from step 2.

Now you have installed the most recent older version of pip for python 2.7.

I think now I will have to manually download all modules from python 2.7 that I have and need so that I can reliably install them again or in another computer because those versions are no longer supported. Many people recommend to upgrade to newer versions, but what they don't seem to understand is that many other software APIs require older versions. Many of us don't have the money to upgrade the software as well.

His answered 18/8, 2023 at 3:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.