Using pyenv with virtualenv and pip cheat sheet

I made some notes on how to use a specific python version with pyenv and using virtualenv to manage packages.

using pyenv

https://github.com/yyuu/pyenv

installation


$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv

initialization


$ export PYENV_ROOT="$HOME/.pyenv"
$ export PATH="$PYENV_ROOT/bin:$PATH"
$ eval "$(pyenv init -)"

use command completion


$ source ~/.pyenv/completions/pyenv.bash

(homebrew on mac)

$ mkdir ~/pyenv/completions
$ cp /usr/local/Cellar/pyenv/20150601/completions/pyenv.bash ~/.pyenv/completions/pyenv.bash

use pyenv to install python versions


$ pyenv install 2.7.10
$ pyenv install 3.4.3

choose a python version with pyenv


$ pyenv shell PYENV_VERSION=2.7.10

upgrade pyenv


$ cd ~/.pyenv; git pull

(homebrew on mac)

$ brew upgrade pyenv

run `pyenv rehash` when you install a new python or binary package


$ pyenv rehash

install pyenv-pip-rehash to rehash automatically when you use pip

(as pyenv plugin)

$ git clone https://github.com/yyuu/pyenv-pip-rehash.git ~/.pyenv/plugins/pyenv-pip-rehash

(homebrew on mac)

$ brew install homebrew/boneyard/pyenv-pip-rehash

install pyenv-virtualenv


$ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv

intialize pyenv-virtualenv


$ eval "$(pyenv virtualenv-init -)"

(homebrew on mac)

$ brew install pyenv-virtualenv

create a virtualenv with pyenv


$ pyenv virtualenv 2.7.10 my-virtual-env

list existing virtualenvs


$ pyenv virtualenvs

use a virtualenv


$ pyenv activate my-virtual-env
$ pyenv deactivate my-virtual-env

delete a virtualenv


$ pyenv uninstasll my-virtual-env

Advertisements

3 thoughts on “Using pyenv with virtualenv and pip cheat sheet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s