0

In Ubuntu I have Python3 as default and pip and pip3. Now I need Python2 to install an app. I have Python2 installed but not pip2. If I try

sudo python2 -m pip install my_app 

or

sudo python2 -m pip2 install my_app 

I get:

No module named pip 

If I install pip2 via easy_install or get-pip.py will it make me problems with pip which is for Python3? What is the right way?

2 Answers 2

3

You can safely install pip for both py2.x and py3.x simultaneously. You can explicitly specify which pip to use by using pip2 for py2.x or pip3 for py3.x.

sudo apt-get install python-pip installs pip2
while
sudo apt-get install python3-pip installs pip3

also to keep things simple, just using
sudo pip2 install my_app
will suffice.

EDIT: I have noticed that in some cases even pip3 calls the python2.x interpreter. To be on a totally safe side I recommend using -
sudo python2 -m pip install my_app for python2.x and
sudo python3 -m pip install my_app for python3.x

Sign up to request clarification or add additional context in comments.

Comments

0

sudo apt-get install python-pip

Is a right command to my knowledge. Bit I don't think the other methods will interrupt your python3 but no experience with those.

2 Comments

there is no such package - python2-pip
Aah thanks I know for python3-pip it works as python2 is the default on my pc so I imagened if python3 was your default you'd need to add the 2 there for the non default

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.