0

How to make pip point to python 2 instead of python 3 (as it normally should be)?

I want to install a package that is compatible only with python 2 and I use the pip command but it installs the package for python 3.

[root@q~]# python -V
Python 2.7.5
[root@q~]# python3 -V
Python 3.4.9
[root@q~]# pip -V
pip 19.0.1 from /usr/lib/python3.4/site-packages/pip (python 3.4)
[root@q~]# pip3 -V
pip 19.0.1 from /usr/lib/python3.4/site-packages/pip (python 3.4)

[root@q~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@q~]# whereis python
python: /usr/bin/python2.7 /usr/bin/python /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python3.4-config /usr/bin/python3.4m-config /usr/bin/python3.4m-x86_64-config /usr/lib/python2.7 /usr/lib/python3.4 /usr/lib64/python2.7 /usr/lib64/python3.4 /etc/python /usr/include/python2.7 /usr/include/python3.4m /opt/borg-env/bin/python /opt/borg-env/bin/python3.4 /usr/share/man/man1/python.1.gz
[root@q~]# whereis python3
python3: /usr/bin/python3 /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python3.4-config /usr/bin/python3.4m-config /usr/bin/python3.4m-x86_64-config /usr/lib/python3.4 /usr/lib64/python3.4 /usr/include/python3.4m /opt/borg-env/bin/python3 /opt/borg-env/bin/python3.4 /usr/share/man/man1/python3.1.gz

[root@q~]# whereis pip
pip: /usr/bin/pip /usr/bin/pip3.4 /opt/borg-env/bin/pip /opt/borg-env/bin/pip3.4
[root@q~]# whereis pip3
pip3: /usr/bin/pip3 /usr/bin/pip3.4 /opt/borg-env/bin/pip3 /opt/borg-env/bin/pip3.4
liberand
  • 9
  • 2

2 Answers2

0

Since you have Python < 2.7.9, then you must install Pip manually

Remove pip with sudo mv /usr/bin/pip /usr/bin/pip.BAK

Then

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

Depending on your OS, then using its package manager may also work


Note that Python2 is EOL by the end of the year, so you should find a different library or update it

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
-1

Sounds like you do not have python-pip installed for python2.

Try running this:

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

Or this:

wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py

You can also try this if you are on debian:

sudo apt-get install python-pip
gkpln3
  • 1,317
  • 10
  • 24