Setup Python Development Environment On Mac

 ·  · 

1. Install pip

Now pip is bundled with Python3. Following commands is installing pip for Python2.x.

$ curl --silent --show-error | sudo python

Check the version of pip:

$ pip --version

You'd better update the setuptools after installing pip.

$ sudo pip install --upgrade setuptools


2. Install IPython

$ sudo pip install ipython


3. Install virtualenv

$ sudo pip install virtualenv


4. Install virtualenvwrapper

$ sudo pip install virtualenvwrapper

Append lines below to ~/.profile file:

export WORKON_HOME=$HOME/your_virtualenvs_folder
export PROJECT_HOME=$HOME/your_develop_workspace_folder
source /usr/local/bin/
# or for lazy loading
# source /usr/local/bin/

Save and load it at once:

$ source ~/.profile


5. Quick Guide For virtualenvwrapper Commands

5-1. How to list all existing virtualenvs:

$ lsvirtualenv

5-2. How to create a new virtualenv:

$ mkvirtualenv env_name

5-3. How to deactivate a virtualenv:

$ deactivate

5-4. How to activate a existing virtualenv:

$ workon env_name

5-5. How to create a virtualenv and a project together

To create a new project under $PROJECT_HOME and create a new virtualenv under $WORKON_HOME, meantime also bind the created virtualenv to the created project:

$ mkproject project_name

To switch current working directory to a named project folder and enter the linked virtualenv at the same time:

$ cdproject project_name

5-6. How to bind a virtualenv to a project:

$ setvirtualenvproject virtualenv_folder_path project_folder_path

5-7. How to remove a virtualenv:

$ rmvirtualenv env_name