Setup Python on OSX
Python is already installed on OS X and it's relatively easy to install both pip and virtualenv.
- From a terminal window, run the following command
sudo easy_install pip
- Using pip to install virtualenv, run the following command in a terminal window
sudo pip install virtualenv
Now that virtualenv and pip are installed, let's test out virtualenv to make sure that it's working. We've already tested pip installing virtualenv.
Open a terminal and navigate to some directory under your home (assuming /User/monty/code)
- cd ~/code
- virtualenv --distribute env_test
- source env_test/bin/activate
You should now have an active virtualenv which is separate from the system libraries. Your command prompt should look something like
You can install whatever you want in the new virtualenv using pip:
(env_test)montys-MacBook-Pro:code monty$ pip install pytest Downloading/unpacking pytest Downloading pytest-2.3.4.zip (527kB): 527kB downloaded Running setup.py egg_info for package pytest Downloading/unpacking py>=1.4.12 (from pytest) Downloading py-1.4.12.zip (227kB): 227kB downloaded Running setup.py egg_info for package py Installing collected packages: pytest, py Running setup.py install for pytest Installing py.test script to /Users/monty/code/env_test/bin Installing py.test-2.6 script to /Users/monty/code/env_test/bin Running setup.py install for py Successfully installed pytest py Cleaning up...