Skip to content

Instantly share code, notes, and snippets.

@jessedc
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessedc/11274419 to your computer and use it in GitHub Desktop.
Save jessedc/11274419 to your computer and use it in GitHub Desktop.
Setting up a python development environment on OSX without needing to use sudo

Assumptions

Using sudo for local development tooling is a bad idea. This is the bare minimum to get your python environment up and running so you can install pip and virtualenv at the user level and then continue to use [virtualenv][1] to get your own project environments running.

  • OSX 10.9+
  • You have homebrew installed
  • /usr/loca/bin is part of your $PATH

Find where the system python version is

$ ls /usr/local/lib | grep python
python2.7

Create a location to install future python packages

mkdir -p /usr/local/lib/python2.7/site-packages

Create .pydistutils config file

Use your favourite editor.

subl ~/.pydistutils.cfg

Add the following lines

[install]
install_lib = /usr/local/lib/python$py_version_short/site-packages
install_scripts = /usr/local/bin

Add PYTHONPATH to your .bash_profile or similar

export PYTHONPATH=/usr/local/lib/python2.7/site-packages

Now reload your configuration

source ~/.zshrc

Install pip with easy_install without sudo

easy_install pip

Install virtualenv

pip install virtualenv

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment