ImportError: No module named site (Python, Apache2, Django, virtualenv, Dropbox)

I was getting a lot of “ImportError: No module named site”:

ImportError: No module named site
ImportError: No module named site
ImportError: No module named site

A Google search brought up that it’s a Python module issue. I did a
“locate site” and found site.pyc.

In my apache2 based setup, I had my Python code (for Django) using a virtualenv.

A Dropbox Gotcha

Recently, the virtualenv directory, “env”, had been damaged by Dropbox’s sync. It just refused to sync that directory correctly – and it was damaging it everywhere  – so I switched to using the Dropbox selective sync feature and removed ‘env’ from the sync.

The fix was to create a new virtualenv, called “env”, and use pip to install the packages there. You need to keep a list of packages and installation instructions, because this can happen.