Install easy_install, pip, virtualen
sudo apt-get install python-setuptools python-virtualenv python-pip
Create virtual environment
$ virtualenv --no-site-packages env # from version 1.7 --no-site-packages default behavior
$ source env/bin/activate
(env)$ export PYTHONPATH= # sometimes required
(env)$ pip install django
# ...
(env)$ pip freeze > requirements.txt
(env)$ deactivate
$ virtualenv --no-site-packages env2
$ source env2/bin/activate
(env2)$ pip install -r requirements.txt
Pip
# concrete package version
(env)$ pip install ipython==0.11
# archive link
(env)$ pip install -f http://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.0/matplotlib-1.0.0.tar.gz matplotlib
# install for concrete python interpreter version
sudo pip install ipython -E python2.5
Bonuses
List all packages with requirements:
pip list --local | awk '{print $1}' | xargs pip show | grep -v -e '^Location' -e '^Requires: $'
yolk - list installed packages
(env2)$ pip install yolk
(env2)$ yolk -l
vanity - list available versions
(env2)$ pip install vanity
(env2)$ vanity django -v
PyCharm
If you use PyCharm you’ll want to set up your virtualenv there for your project.
Edit your project settings. Select Python Interpreter -> Add -> Specify Other…
Add python from your virtual_env (env/bin/python)
No comments:
Post a Comment