7

I followed the link @https://linuxize.com/post/how-to-install-pip-on-centos-7/#2-install-pip to install pip ,however its intalled for python 2.6 that comes with the system,how do I install it for python 2.7?

sudo yum install epel-release
Loaded plugins: security
Setting up Install Process
Package epel-release-6-8.noarch already installed and latest version
Nothing to do

Installing pip

 sudo yum install python-pip
Loaded plugins: security
Setting up Install Process
Package python-pip-7.1.0-1.el6.noarch already installed and latest version
Nothing to do

pip version

pip --version
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)

Machine configuration:

LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: OracleServer
Description:    Oracle Linux Server release 6.6
Release:    6.6
Codename:   n/a

/usr/local

enter image description here

user3508811
  • 847
  • 4
  • 19
  • 43
  • Possible duplicate of [Can't install pip on python 2.7, only python 3](https://stackoverflow.com/questions/50805485/cant-install-pip-on-python-2-7-only-python-3) – phd Jan 20 '19 at 12:36
  • https://stackoverflow.com/search?q=%5Bpip%5D+install+pip+Python+2.7 – phd Jan 20 '19 at 12:36
  • None of the above solved my problems...like I said am usine OracleServer 6.6 – user3508811 Jan 20 '19 at 18:09
  • The accepted answer there works everywhere, Linux, w32, MacOS… – phd Jan 20 '19 at 18:29
  • @phd That gave me an error `$ python get-pip.py pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Collecting pip .. Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping Could not find a version that satisfies the requirement pip (from versions: ) No matching distribution found for pip` – user3508811 Jan 20 '19 at 21:41
  • https://stackoverflow.com/search?q=%5Bpip%5D+is+configured+with+locations+that+require+TLS%2FSSL%2C+however+the+ssl+module+in+Python+is+not+available – phd Jan 20 '19 at 21:59
  • I couldnt find anything that works for python 2.7,I am still stuck at the same error,I tried https://stackoverflow.com/questions/44290926/pip-cannot-confirm-ssl-certificate-ssl-module-is-not-available , I tried `yum install openssl-devel -y` but I couldnt find any sources to hack as mentioned in the second solution in the link I shared – user3508811 Jan 21 '19 at 04:17
  • If you don't get an answer here, you might want to try [Unix & Linux Stack Exchange](https://unix.stackexchange.com/) – wjandrea Jan 22 '19 at 19:03

4 Answers4

25

Try installing manually:

wget -P ~/.local/lib https://bootstrap.pypa.io/pip/2.7/get-pip.py
python2.7 ~/.local/lib/get-pip.py --user 
#if using bash
printf "\nPATH=\$PATH:~/.local/bin/" >> ~/.bashrc
source ~/.bashrc
ErikWi
  • 514
  • 5
  • 11
  • 1
    This fails at step2 with error `Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping Could not find a version that satisfies the requirement pip (from versions: ) No matching distribution found for pip` – user3508811 Jan 24 '19 at 04:04
  • how to get rid of this SSL error?this has been the blocker for me – user3508811 Jan 24 '19 at 04:08
  • Did you compile python yourself? Have you got OpenSSL? See fx https://stackoverflow.com/questions/44290926/pip-cannot-confirm-ssl-certificate-ssl-module-is-not-available/46087798#46087798 – ErikWi Jan 24 '19 at 05:12
  • No,I didn't compile python myself...I don't seem to able to find the python source under `/usr/local` ,how to I find the source? – user3508811 Jan 24 '19 at 18:33
  • I added a screen shot of how my `/usr/local` looks – user3508811 Jan 24 '19 at 18:47
  • Try installing OpenSSL: ‘yum install openssl’ – ErikWi Jan 24 '19 at 21:04
  • ‘yum install openssl’ throws the output `Loaded plugins: security Setting up Install Process Package openssl-1.0.1e-57.0.6.el6.x86_64 already installed and latest version Nothing to do` – user3508811 Jan 24 '19 at 23:31
  • Strange, did you install python 2.7 from epel, with yum? – ErikWi Jan 25 '19 at 05:34
  • It was already present on the machine am using, so am not sure how it was installed,anyway to recover from this situation? – user3508811 Jan 25 '19 at 22:44
  • Python 2 will soon be End of life, can you use python 3? yum install python3. If not, yum install python2.7 to make sure it’s all there? – ErikWi Jan 26 '19 at 05:48
  • yum list python* – ErikWi Jan 26 '19 at 05:57
  • 1
    has been updated to: https://bootstrap.pypa.io/pip/2.7/get-pip.py. The url in your post will now only work with Python3 – raw-bin hood May 11 '21 at 01:40
2

In newer versions of Ubuntu such as 20.04, python-pip is no longer a package. Therefore, the old:

sudo apt install python-pip

Will fail.

Here's how to work around this issue:

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
python get-pip.py

Link: https://www.how2shout.com/linux/how-to-install-python-2-7-on-ubuntu-20-04-lts-linux/

0

pip has dropped a 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
-3

Just go into terminal and type in:

sudo apt-get install python-pip

I know that this at least works on a raspberry pi.

Akhil
  • 912
  • 12
  • 23
John Mobey
  • 79
  • 1
  • 8