What's the proper way to install pip, virtualenv, and distribute for Python? -


short question

background

in my answer so question 4314376, recommended using ez_setup install pip , virtualenv follows:

curl -o http://peak.telecommunity.com/dist/ez_setup.py sudo python ez_setup.py sudo easy_install pip sudo pip install virtualenv 

i pulled these instructions jesse noller's blog post so want use python on mac?. idea of keeping clean global site-packages directory, other packages install there virtualenvwrapper , distribute. (i added distribute toolbox because of this python public service announcement. install these 2 packages, used:

sudo pip install virtualenvwrapper curl -o http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py 

no more setuptools , easy_install

to follow that python public service announcement, on fresh python install, following:

curl -o http://python-distribute.org/distribute_setup.py sudo python distribute_setup.py sudo easy_install pip sudo pip install virtualenv sudo pip install virtualenvwrapper 

glyph's rebuke

in comment my answer so question 4314376, user glyph stated:

no. never ever sudo python setup.py install whatever. write ~/.pydistutils.cfg puts pip installation ~/.local or something. files named ez_setup.py tend suck down newer versions of things setuptools , easy_install, can potentially break other things on operating system.

back short question

so glyph's response leads me original question:

you can without installing anything python itself.

you don't need sudo or privileges.

you don't need edit files.

install virtualenv bootstrap virtual environment. use virtual environment create more. since virtualenv ships pip , distribute, 1 install.

  1. download virtualenv:
  2. unpack source tarball
  3. use unpacked tarball create clean virtual environment. virtual environment used "bootstrap" others. of virtual environments automatically contain pip , distribute.
  4. using pip, install virtualenv bootstrap environment.
  5. use bootstrap environment create more!

here example in bash:

# select current version of virtualenv: version=12.0.7 # name first "bootstrap" environment: initial_env=bootstrap # set whatever python interpreter want first environment: python=$(which python) url_base=https://pypi.python.org/packages/source/v/virtualenv  # --- real work starts here --- curl -o $url_base/virtualenv-$version.tar.gz tar xzf virtualenv-$version.tar.gz # create first "bootstrap" environment. $python virtualenv-$version/virtualenv.py $initial_env # don't need anymore. rm -rf virtualenv-$version # install virtualenv environment. $initial_env/bin/pip install virtualenv-$version.tar.gz 

now can use "bootstrap" environment create more:

# create second environment first: $initial_env/bin/virtualenv py-env1 # create more: $initial_env/bin/virtualenv py-env2 

go nuts!

note

this assumes not using old version of virtualenv. old versions required flags --no-site-packges (and depending on version of python, --distribute). can create bootstrap environment python virtualenv.py path-to-bootstrap or python3 virtualenv.py path-to-bootstrap.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -