Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip and pip3 - both pointing to python3.5?

I started to experiment with shade today; and installed it for both python2 and python3 on my ubuntu 16.04 system; using:

sudo pip install shade

respectively

sudo pip3 install shade

Both commands passed; I didn't really pay attention.

Then I tried to run this little test script:

from shade import *

simple_logging(debug=True)
conn = openstack_cloud(cloud='myopenstack')
images = conn.list_images()
for image in images:
  print(image)

Using python3, I got a certificate error (which is fine, I would be rather surprised to find our internal infrastructure to use correct certificates).

But just to be sure, I wanted to run with python2.7, too; and I am told:

ImportError: No module named shade

So, I had a closer look what pip and pip3 have to say:

> pip -V
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
> pip3 -V
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)

It looks like both pip and pip3 are actually working on my python3 installation, but when I do:

 > python --version
 Python 2.7.12
 > python3 --version
 Python 3.5.2

Any idea, anybody? What could be causing this, or how to actually install shade for python2/pip?

As requested:

> for i in pip pip3 python python3 ; do type $i ; done
pip is /usr/local/bin/pip
pip3 is /usr/local/bin/pip3
python is /usr/bin/python
python3 is /usr/bin/python3
like image 340
GhostCat Avatar asked Feb 16 '17 19:02

GhostCat


Video Answer


2 Answers

pip3 looks like the default option pip uses. Try using pip2 instead to explicitly install a Python 2 package.

like image 93
kichik Avatar answered Oct 05 '22 08:10

kichik


Just change the first line of the /usr/local/bin/pip to:

#!/usr/bin/python

and the first line of /usr/local/bin/pip3 to:

#!/usr/bin/python3

And then it will act normally:

> pip -V
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
> pip3 -V
pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
like image 33
Lynten Avatar answered Oct 05 '22 07:10

Lynten