Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any trick to make get-pip.py install a specific pip version?

Tags:

python

pip

PIP was recently (yesterday) upgraded from 1.5.6 to 6.0.1. It broke a couple of my stuff. I'm looking for a way to make the "get-pip.py" script install 1.5.6 instead of the latest version.

Any ideas?

like image 974
omribahumi Avatar asked Dec 23 '14 10:12

omribahumi


People also ask

How do I install a specific version of pip?

How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1. 3 .

Does Python 3.9 have pip?

The current version of pip works on: Windows, Linux and MacOS. CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.


3 Answers

This is a relatively old question, but I discovered today that recent versions of get-pip.py allow you to pass in an argument such as pip<6 to ensure that the pip version installed is < 6:

[Nautilus@Nautilus scripts]$ python get-pip.py "pip<6"
Collecting pip<6
  Downloading pip-1.5.6-py2.py3-none-any.whl (1.0MB)
    100% |████████████████████████████████| 1.0MB 608kB/s 
Installing collected packages: pip
Successfully installed pip-1.5.6

This seems to work with any argument form you could pass to pip itself, e.g. >, <, <=, >=, and ==

like image 101
MPlanchard Avatar answered Oct 24 '22 04:10

MPlanchard


As I tried to explain in the comments, get-pip.py in meant to be a bootstrapping method for pip. The problem it aims to solve is that you need pip to install pip.

The script does not allow the user to choose which version of pip you will get, it automatically downloads the latest version.

You can adapt the script and change

def bootstrap(tmpdir=None):
    # Import pip so we can use it to install pip and maybe setuptools too
    import pip

    # We always want to install pip
    packages = ["pip"]

to

def bootstrap(tmpdir=None):
    # Import pip so we can use it to install pip and maybe setuptools too
    import pip

    # We always want to install pip
    packages = ["pip==1.5.6"]

Now the script should always install pip-1.5.6 instead of the latest version found on pypi.

like image 30
cel Avatar answered Oct 24 '22 03:10

cel


I'm not sure how you're running your script, but you should be able to pull off something like:

python get-pip.py && pip install -I pip==1.5.6

You may need to prepend sudo to both commands.

https://pip.pypa.io/en/latest/reference/pip_install.html#cmdoption-I

like image 4
Reut Sharabani Avatar answered Oct 24 '22 04:10

Reut Sharabani