Skip to content

Instantly share code, notes, and snippets.

@iankronquist
Last active August 29, 2015 14:04
Show Gist options
  • Save iankronquist/3b0ac82ec52ed5b77e24 to your computer and use it in GitHub Desktop.
Save iankronquist/3b0ac82ec52ed5b77e24 to your computer and use it in GitHub Desktop.
How to use pip and virtualenv
---------------------------------
virtualenv is a program for managing python dependencies. If you have virtualenv installed you can manage use different versions of libraries and python with ease.
Install virtualenv at the system level with one of these:
```shell
$ brew install pyenv-virtualenv #osx w/homebrew
$ sudo pacman -S python2-virtualenv #arch linux
$ sudo apt-get install python-virtualenv #ubuntu
```
A virtualenv will have its own copy of python, pip, and any python packages you need.
I keep my virtualenvs in `~/venv`.
To create a virtualenv do:
```shell
$ virtualenv ~/venv/$SOMENAME
```
This will create a directory called `$SOMENAME` and install python, pip, and some scripts for managing the virtualenv. It will also rewrite your python path to point to the virtualenv.
I suggest you use `isobar` for `$SOMENAME`.
To activate your virtualenv with a bourne capatable shell (sh, bash, zsh, etc.) do:
```shell
$ source ~/venv/$SOMENAME/bin/activate
```
If you're using a ~~stupid~~ shell like fish do:
```shell
$ source ~/venv/$SOMENAME/bin/activate.fish
```
Now we need to install dependencies.
Since isobar has not been uploaded to the python package index (pypi), we'll install it with pip.
```shell
$ pip install -r requirements.txt
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment