PIP¶
Install pip¶
# install setup tools
curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | python -
# install pip
curl -L https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python -
Use mirror to install packages¶
What to do when PyPI goes down
Using Mirror Flag:
pip install --use-mirrors Django==1.6
virtualenv¶
install it:
pip install virtualenv
make a virtualenv:
cd /srv/www/project_name
virtualenv --no-site-packages env
start it:
source env/bin/activate
install package manager:
pip install django==1.8
pyenv¶
Install build packages:
$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils
https://github.com/yyuu/pyenv/wiki/Common-build-problems
Install pyenv:
$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
Add pyenv configuration to ~/.bashrc
:
$ vim ~/.bash_profile
# pyenv
export PATH="/home/or/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Update it:
$ Update
Uninstall it:
$ rm -rf `pyenv root`
Walk through:
$ pyenv global
$ pyenv versions
* system (set by ~/.pyenv/version)
$ pyenv install 2.7.5
$ pyenv global 2.7.5
Using pyenv virtualenv with pyenv:
$ pyenv virtualenv 2.7.5 env2.7.5
$ pyenv virtualenvs
$ pyenv activate env2.7.5
$ python -V
$ pip list
$ pyenv deactivate
$ which python
Sets the location where python-build stores temporary files
$ export TMPDIR="/tmp/pyenv"
See all available versions:
$ pyenv install --list
https://github.com/yyuu/pyenv-virtualenv
https://github.com/yyuu/pyenv-installer
Fixed bz2 warnings¶
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
$ sudo apt-get install libbz2-dev
How do I install python-ldap in a virtualenv?¶
$ apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
$ (env) pip install python-ldap
Install python modules without root access¶
$ pip install --user package_name
Pip install from git repo branch¶
$ pip install git+https://github.com/ansible/ansible