just use virutalenv

plz just use it like so:

virtualenv --python /usr/bin/python2.7 --system-site-packages env


on new computer

  1. from sourabh bajaj
brew install python
brew install python@2
pip install --upgrade setuptools
pip install --upgrade pip
  1. "Executable scripts from Python packages you install will be put in /usr/local/share/python, make sure it's on your PATH."

  2. from .zshrc via oh-my-zsh:

Python modules have been installed and Homebrew's site-packages is not in your Python sys.path, so you will not be able to import the modules this formula installed. If you plan to develop with these modules, please run:

mkdir -p /Users/tyler/Library/Python/2.7/lib/python/site-packages

echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/tyler/Library/Python/2.7/lib/python/site-packages/homebrew.pth

after that do something like this ~ (all of these work with pip3 & python3 as well, if one doesn't work try the other)

test it out w/ this cute bs4 nugget

# my_parser.py
!#/usr/bin/env python

from bs4 import BeautifulSoup

messy = """

pip install bs4
pip install beautifulsoup
python parser.py


site.addsitedir(sitedir, known_paths=None)

Add a directory to sys.path and process its .pth files. Typically used in sitecustomize or usercustomize (see above).


A list of strings that specifies the search path for modules. Initialized from the environment variable PYTHONPATH, plus an installation-dependent default.

Module site

This describes how to use .pth files to extend sys.path.