skip to Main Content

I’m struggling to install the python pip module on my centOS server which is running on python2.6.6(centOS 6) or python 2.7.5(CentOS7). Due to some reasons I’m not able to upgrade the python version to 3 or later. So in the case, how can I install a legacy PIP version line pip 20 with my python2.6 or python 2.7 platform?
Thanks.

2

Answers


  1. If you have Python 2, you most likely have pip. Try python2 -m pip install foobar.

    Turns out that in CentOS7 pip is not available in distro repos by default. You need to yum install epel-release to enable the EPEL repo, which in turn contains pip: yum install python-pip.

    So do this: (as root/using sudo)

    yum install epel-release
    yum makecache
    yum install python-pip
    
    Login or Signup to reply.
  2. You can use get-pip.py for 2.7. Here’s an example in a centos:7 Docker container:

    $ python -V
    Python 2.7.5
    $ curl -fsSL -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
    $ python get-pip.py --no-python-version-warning && rm -f get-pip.py
    $ python -m pip --version
    pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (python 2.7)
    

    Docs: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py. (Though admittedly, they don’t go out of their way to point out the presence of the 2.6/2.7 branches, given that Python 2 is prominently EOL.)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search