Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't install pip anymore with python 2.7?

Tags:

python

pip

eol

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
like image 357
colorf Avatar asked Jan 04 '21 05:01

colorf


People also ask

Why is pip install not working in python?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.

Does python 2.7 16 have pip?

Python 2.7 must be having pip pre-installed. Try installing your package by: Open cmd as admin. ( win+x then a )

Can python 2.7 run pip3?

You have to use pip3 for it to be installed on Python3. So to install packages in python3, you should use pip3. NOTE:- Its not necessary that pip will install in python 2.7, if python2 is absent then pip will do it in python3. The above statement was if you have both the version of python installed.

Is pip for python2?

pip installation To use pip, first install a custom version of Python 2. pip is then installed with it. You can then use the pip command to create a virtualenv and install modules.


5 Answers

pip install --upgrade "pip < 21.0"
like image 151
Ryan Liu Avatar answered Sep 30 '22 23:09

Ryan Liu


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)
like image 32
Alex Punnen Avatar answered Sep 30 '22 23:09

Alex Punnen


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
like image 25
harshi gupta Avatar answered Oct 02 '22 23:10

harshi gupta


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.

like image 29
betontalpfa Avatar answered Oct 03 '22 23:10

betontalpfa


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

like image 38
Amaury D Avatar answered Oct 01 '22 23:10

Amaury D