What's the proper way to install pip, virtualenv, and distribute for Python? -
short question
- what proper way install
pip
,virtualenv
, ,distribute
?
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 namedez_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:
- what proper way install
pip
,virtualenv
, ,distribute
?
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.
- download virtualenv:
- http://pypi.python.org/pypi/virtualenv
- https://pypi.python.org/packages/source/v/virtualenv/virtualenv-12.0.7.tar.gz (or whatever latest version!)
- unpack source tarball
- use unpacked tarball create clean virtual environment. virtual environment used "bootstrap" others. of virtual environments automatically contain pip , distribute.
- using pip, install virtualenv bootstrap environment.
- 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
Post a Comment