I have both python2.7
and python3.2
installed in Ubuntu 12.04
.
The symbolic link python
links to python2.7
.
When I type:
sudo pip install package-name
It will default install python2
version of package-name
.
Some package supports both python2
and python3
.
How to install python3
version of package-name
via pip
?
Easy enough:
If you want Python 3.3, which isn't the default as of Ubuntu 12.10:
You should install ALL dependencies:
sudo apt-get install build-essential python3-dev python3-setuptools python3-numpy python3-scipy libatlas-dev libatlas3gf-base
Install pip3(if you have installed, please look step 3):
sudo apt-get install python3-pip
Iinstall scikit-learn by pip3
pip3 install -U scikit-learn
Open your terminal and entry python3 environment, type
import sklearn
to check it.Gook Luck!
Short Answer
Source: Shashank Bharadwaj's comment
Long Answer
The short answer applies only on newer systems. On some versions of Ubuntu the command is
pip-3.2
:If it doesn't work, this method should work for any Linux distro and supported version:
If you don't have
curl
, usewget
. If you don't havesudo
, switch toroot
. Ifpip3
symlink does not exists, check for something like pip-3.XMuch python packages require also the dev package, so install it too:
Sources:
python installing packages with pip
Pip latest install
Check also Tobu's answer if you want an even more upgraded version of Python.
I want to add that using a virtual environment is usually the preferred way to develop a python application, so @felixyan answer is probably the best in an ideal world. But if you really want to install that package globally, or if need to test / use it frequently without activating a virtual environment, I suppose installing it as a global package is the way to go.
Execute the pip binary directly.
First locate the version of PIP you want.
Then execute.
If you just installed Python 3.3 and now want to install pip 3.3 locally:
This works in Ubuntu 12.04. Don't forget to add
$HOME/.local/bin
to your path.You can alternatively just run
pip3 install packagename
instead ofpip
,