Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get pip to point to newer version of Python

I have two versions of Python installed on my centOS server.

[ethan@demo ~]$ python2.6 --version
Python 2.6.6
[ehtan@demo ~]$ python --version
Python 2.7.3

The older version (2.6) is required by some essential centOS packages so I can't remove it.

When I install packages using pip, they are being installed in Python 2.6. But instead I want them to be installed to Python 2.7.

How can I change this behaviour?

For example, here is what happened when I tried installing Wand

[ethan@demo ~]$ pip install Wand
Requirement already satisfied (use --upgrade to upgrade): Wand in /usr/lib/python2.6/site-packages
Cleaning up...
[ethan@demo ~]$ python2.6
Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wand
>>> exit()
[ethan@demo ~]$ python
Python 2.7.3 (default, Oct 11 2013, 15:59:28) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import wand
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named wand
>>> exit()

Edit

I found this answer but it didn't work for me https://stackoverflow.com/a/4910393/3384340

like image 250
Ethan Avatar asked Mar 21 '14 14:03

Ethan


People also ask

How do I update pip to latest version of Python?

Updating Pip b is available.” You can run “pip install --upgrade pip” to install and use the new version of pip. To update pip2 or pip3 using this command, only replace the first pip with the pip version.

Does Python 3.10 support pip?

Pip is not working for Python 3.10 on Ubuntu - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.

Does Python 3.9 support pip?

Once the path is added, open a fresh CMD window and type pip --version . Show activity on this post. I found that for Python 3.9 if you enter the command as py -m pip install , the installation initiates as expected.


1 Answers

You need to install pip for each python version separately.

In order to install pip for Python2.7, run

sudo easy_install-2.7 pip

Use pip-2.7 to install Wand

sudo pip-2.7 install Wand

like image 67
Forge Avatar answered Oct 19 '22 10:10

Forge