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.
Asked
Active
Viewed 3,487 times
1
-
Python 2 is to be no longer supported soon: https://www.python.org/doc/sunset-python-2/ – loa_in_ Jan 26 '21 at 11:17
-
@loa_in_ How soon? – superb rain Jan 26 '21 at 11:19
-
As of January 1st, 2020 no new bug reports, fixes, or changes will be made to Python 2, and Python 2 is no longer supported. – loa_in_ Jan 26 '21 at 11:19
-
2That's extremely soon. Over a year ago. – loa_in_ Jan 26 '21 at 11:20
-
@loa_in_ So your "soon" is in the past? – superb rain Jan 26 '21 at 11:20
-
as per PIP website,--' PIP20.3 is the last version supported python 2..', that's why I'm asking-- I just want to install the pip v.20 or earlier version on my python 2 platform, any idea? – Dacman2018 Jan 26 '21 at 11:24
-
https://bootstrap.pypa.io/2.6/, https://bootstrap.pypa.io/2.7/ – phd Jan 26 '21 at 11:24
2 Answers
1
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.)

Brad Solomon
- 38,521
- 31
- 149
- 235
-
Thanks a lot Brad. Just follow the steps as you said I have got the pip 20.3.4 installed and I'm finally able to get the service up and running again:).Much appreciated. – Dacman2018 Jan 27 '21 at 07:40
0
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

loa_in_
- 1,030
- 9
- 20
-
Thanks loa_in. But when I type in 'python2 -m pip install foobar', I got an Error '/usr/bin/python2: No module named pip' – Dacman2018 Jan 26 '21 at 11:58
-
As per PIP website---'pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org ...' Actually I'm using python 2.7.5 which comes with the centOS 7 system. – Dacman2018 Jan 26 '21 at 12:01
-
@Dacman2018 Here: https://pip.pypa.io/en/stable/installing/ you can read: `If you installed Python from a package manager on Linux, you should always install pip for that Python installation using the same source.` – loa_in_ Jan 26 '21 at 12:38
-
1"If you have Python 2, you most likely have pip." - not really. As you point out yourself, it is common for stuff like CentOS to just have easy_install and (maybe) setuptools out of the box. – Brad Solomon Jan 26 '21 at 12:57