I have had this problem several times. Although I cannot say for sure what the actual problem is, I believe that this basically means that some files in the python virtualenv package have become corrupted.
I keep my virtual environment in a synchronized Dropbox folder, so this can be a big cause of the problem.
Restoring a virtual environment from a backup archive worked for me. Or just reinstall the identical virtual environment.
- First try activating the failed environment using
cd <path/to/old_env> and source /bin/activate . - If it is successfully activated,
cd to an accessible place on the disk and run pip freeze > requirements.txt to export the list of installed Python modules. - Remove old medium.
- Install the new virtual environment of the latest version of Python 2 that you use on your computer via
virtualenv <path/new_env> - Or, if you want to use a specific version of Python, first make sure you have it on your disk, and then run
virtualenv -p <path> . Assuming you downloaded the Python version using Homebrew, for example: virtualenv -p /usr/local/bin/python2.6 <path/new_env> - Activate the virtual environment through
cd <path/new_env> , and then do source /bin/activate . - Assuming that you saved the list of modules for reinstallation by first doing
pip freeze > requirements.txt , cd in the folder where the text file is located, and doing pip install -r requirements.txt . - Otherwise, reinstall the modules using
pip manually.
source share