What is the official "preferred" way to install pip and virtualenv systemwide?
Solution 1
If you can install the latest Python (2.7.9 and up) Pip is now bundled with it.
See: https://docs.python.org/2.7//installing/index.html
If not :
Update (from the release notes):
Beginning with v1.5.1, pip does not require setuptools prior to running get-pip.py. Additionally, if setuptools (or distribute) is not already installed, get-pip.py will install setuptools for you.
I now run the regular:
curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo python
Here are the official installation instructions: http://pip.readthedocs.org/en/latest/installing.html#install-pip
EDIT 25-Jul-2013:
Changed URL for setuptools install.
EDIT 10-Feb-2014:
Removed setuptools install (thanks @Ciantic)
EDIT 26-Jun-2014:
Updated URL again (thanks @LarsH)
EDIT 1-Mar-2015:
Pip is now bundled with Python
Solution 2
http://www.pip-installer.org/en/latest/installing.html is really the canonical answer to this question.
Specifically, the systemwide instructions are:
$ curl -O http://python-distribute.org/distribute_setup.py
$ python distribute_setup.py
$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ python get-pip.py
The section quoted in the question is the virtualenv
instructions rather than the systemwide ones. The easy_install
instructions have been around for longer, but it isn't necessary to do it that way any more.
Solution 3
This answer comes from @webology on Twitter:
$ sudo apt-get install python-setuptools
$ sudo easy_install pip
$ sudo pip install --upgrade pip virtualenv virtualenvwrapper
My added notes:
- On Mac/Windows (and Linux if the apt repo is outdated) you'd replace the first step with downloading setuptools from http://pypi.python.org/pypi/setuptools
- On Windows you'd have to omit virtualenvwrapper from the last step and install it manually somehow. I don't know if there's a way to do this without Cygwin, but I hope so.
Solution 4
On Ubuntu 12.04 I've had good luck just using the package manager:
sudo apt-get install python-pip virtualenvwrapper
Solution 5
There is no preferred method - everything depends on your needs. Often you need to have different Python interpreters on the system for whatever reason. In this case you need to install the stuff individually for each interpreter. Apart from that: I prefer installing stuff myself instead of depending of pre-packaged stuff sometimes causing issues - but that's only one possible opionion.
Comments
-
coffee-grinder almost 4 years
Is it this, which people seem to recommend most often:
$ sudo apt-get install python-setuptools $ sudo easy_install pip $ sudo pip install virtualenv
Or this, which I got from http://www.pip-installer.org/en/latest/installing.html:
$ curl -O https://github.com/pypa/virtualenv/raw/master/virtualenv.py $ python virtualenv.py my_new_env $ . my_new_env/bin/activate (my_new_env)$ pip install ...
Or something entirely different?
-
coffee-grinder about 13 yearsI'm asking about the preferred method specifically because I'm going to give these instructions to a class of 20 people and don't want to mislead them.
-
lambacck about 13 yearsWhy are you bothering with python-setuptools and then distribute when you can go directly to distribute?
-
coffee-grinder about 13 years@lambacck Could you please post what you are describing in a separate answer (even if it seems repetitive)?
-
coffee-grinder about 13 yearsI know virtualenv comes with pip. Does pip come with virtualenv?
-
opricnik about 13 yearsNo, you would just
pip install virtualenv
after that. -
Carl Meyer about 13 yearsIf the condition is that you want system-wide installations of pip and virtualenv, this is what I generally do. The instructions from the pip docs that are given as the second alternative in the question are based on the premise that we're avoiding installing anything system-wide.
-
Carl Meyer about 13 yearsNot to mention that on any recent Ubuntu (and Debian too? Not sure) the "python-setuptools" package actually IS distribute, so you may as well just skip the specific distribute step.
-
ncoghlan about 13 yearsEdited to clarify the difference between the systemwide instructions on that page and the
virtualenv
instructions that were quoted in the question. -
lambacck about 13 years@coffee-grinder distribute is a fork of setuptools and therefor provides the same functionality (and more). Don't bother doing "apt-get install python-setuptools" unless python-setuptools IS distribute (as Carl indicates it might be) in which case skip steps 2 & 3.
-
JCotton about 11 yearsThe packaged versions are far out of date. 12.04 provides
python-pip 1.0-1build1
which was released in early 2011 andvirtualenvwrapper 2.11.1-21
released January 2012. @Richard Jones' answer will get you the latest. -
Tobu almost 11 years✓ This is the best option if you don't want to rely on distribution packages.
-
Tal Weiss almost 11 yearsUpdate: distribute does not work anymore for pip! See stackoverflow.com/a/17601159/78234
-
Steven Lu almost 11 yearsWhere/how do you install setuptools-0.8? Looks like you are just grabbing
ez_setup.py
for a "lightweight version" of getting pip. I'd do the same but fear that it will break in the near future and I'll get stuck here again (like I always do) -
Steven Lu almost 11 yearsAh, looks like the instructions say to just do as you say here, it is sanctioned. Nevermind then.
-
Dennis over 10 yearsYou can replace the first two commands with
$ sudo apt-get install python-pip
. Installing python-pip will also install python-setuptools. -
Ciantic over 10 yearsThere is new (?) way to do this, this installs pip and setuptools automatically:
wget --no-check-certificate https://raw.github.com/pypa/pip/master/contrib/get-pip.py
and thenpython get-pip.py
(may require sudo) -
Neil Traft about 10 yearsPlease note that the instructions on the linked page no longer match the instructions here. It is best to just visit the official page and do as they say (and why did anyone doubt them in the first place?!)
-
LarsH almost 10 yearsNow the URL for get-pip.py seems to have changed to
https://bootstrap.pypa.io/get-pip.py
. Probably better just to link to the official instructions. -
Tal Weiss almost 10 yearsThanks @LarsH - edited my answer to reflect the change. Again.
-
LarsH almost 10 yearsP.S. Thanks for this answer - it helped me get pip installed.
-
orluke over 9 yearsAny idea if it's possible to specify a specific version of pip by passing an argument to get-pip.py? Otherwise I'd just use the installed pip to install a specified version of pip, e.g.
pip install -U pip==1.5.6
-
Tal Weiss over 9 years@orluke Not sure why you would want to do this, but you can download pip from Github - here are the releases: github.com/pypa/pip/releases
-
cel over 9 yearsThe approach described in this answer is outdated and does not seem to work anymore.
-
georgiecasey about 9 yearsdebian version can be very old. check this answer for more info: unix.stackexchange.com/a/182467/17425