I installed Python 3.x (besides Python 2.x on Ubuntu) and slowly started to pair modules I use in Python 2.x.
So I wonder, what approach should I take to make my life easy by using pip for both Python 2.x and Python 3.x?
This question is related to
python
python-3.x
python-2.7
pip
What you can also do is to use apt-get:
apt-get install python3-pip
In my experience this works pretty fluent too, plus you get all the benefits from apt-get.
Please note that on msys2 I've found these commands to be helpful:
$ pacman -S python3-pip
$ pip3 install --upgrade pip
$ pip3 install --user package_name
If you don't want to have to specify the version every time you use pip:
Install pip:
$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python3
and export the path:
$ export PATH=/Library/Frameworks/Python.framework/Versions/<version number>/bin:$PATH
Thought this is old question, I think I have better solution
To use pip for a python 2.x environment, use this command -
py -2 -m pip install -r requirements.txt
To use pip for python 3.x environment, use this command -
py -3 -m pip install -r requirements.txt
In Windows, first installed Python 3.7 and then Python 2.7. Then, use command prompt:
pip install python2-module-name
pip3 install python3-module-name
That's all
First, install Python 3 pip using:
sudo apt-get install python3-pip
Then, to use Python 3 pip
use:
pip3 install <module-name>
For Python 2 pip
use:
pip install <module-name>
This worked for me on OS X: (I say this because sometimes is a pain that mac has "its own" version of every open source tool, and you cannot remove it because "its improvements" make it unique for other apple stuff to work, and if you remove it things start falling appart)
I followed the steps provided by @Lennart Regebro to get pip for python 3, nevertheless pip for python 2 was still first on the path, so... what I did is to create a symbolic link to python 3 inside /usr/bin (in deed I did the same to have my 2 pythons running in peace):
ln -s /Library/Frameworks/Python.framework/Versions/3.4/bin/pip /usr/bin/pip3
Notice that I added a 3
at the end, so basically what you have to do is to use pip3
instead of just pip
.
The post is old but I hope this helps someone someday. this should theoretically work for any LINUX system.
The shortest way:
python3 -m pip install package
python -m pip install package
On Suse Linux 13.2, pip calls python3, but pip2 is available to use the older python version.
Source: Stackoverflow.com