Maca
Maca

Reputation: 1689

How do I change PIP to use Python 2.7

I am on AWS Ec2 Amazon AMI. Trying to install virtualenv but PIP is set to use Python2.6

# pip -V && virtualenv --version
pip 9.0.1 from /usr/local/lib/python2.6/site-packages/pip-9.0.1-py2.6.egg (python 2.6)
bash: /usr/bin/virtualenv: No such file or directory

# python -V
Python 2.7.12

I tried uninstalling virtualenv and reinstalling it but no luck.

#pip install virtualenv
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Requirement already satisfied: virtualenv in /usr/local/lib/python2.6/site-packages

Here is the install directory:

# which pip
/usr/sbin/pip
# which python
/usr/bin/python

Upvotes: 1

Views: 1056

Answers (1)

Vineet Jain
Vineet Jain

Reputation: 1575

1.python2.7 -m pip install virtualenv
Reference Python official document

2.You can Install virtualenv for any python interpreter and use for a different python interpreter like:-

sudo pip3 install virtualenv 

and then if you want to use python2.7 python interpreter then run following command to make virtualenv:-

virtualenv --python=/usr/bin/python2.7 virtualenv_name

NOTE :- python2.7 interpreter has to be present in /usr/bin/* folder
For more on above command see this answer

Upvotes: 1

Related Questions