Python Virtualenv on OSX

This subject looks easy and simple. However I will introduce the work flow in this post if it means something.

Part I: Use Port to install Python on OSX

sudo port install python26 python_select
sudo port select --set python python26

OR

sudo port install python30 python_select
sudo port select --set python python30

(Do sudo apt-get install python-setuptools python-dev build-essential on Linux)

sudo port install -U pip

Part II: Create virtualenv

sudo easy_install -U pip
sudo easy_install -U virtualenv
virtualenv myenv
$ virtualenv –-python=/usr/bin/python2.7 myenv-py27
$ source /tmp/myenv/bin/activate
$ pip install yolk
$ source /tmp/myenv/bin/activate
$ yolk -l
$ deactivate
$ source /tmp/myenv/bin/activate
$ pip freeze > /tmp/requirements.txt
$ source /tmp/myenv/bin/activate
$ pip uninstall Django

A very useful reference.

Advertisements