Question: I recently installed a bunch of dotfiles on my Mac along with some other applications (I changed to iTerm instead of Terminal, and Sublime as my default text editor) but ever since, all my virtual environments have stopped working, although their folders inside .virtualenvs are still there and they give the following error whenever I try to run anything in them:

```
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /Users/[user]/.virtualenvs/modclass/bin/python
  Reason: image not found
Trace/BPT trap: 5

```

I have removed all the files related to dotfiles and have restored my .bash\_profile to what it was before, but the problem persists. Is there any way to diagnose the problem or solve it in an easy way (e.g. not requiring to create all the virtualenvs all over again)?

Answer: 
I had a broken virtual env due to a Homebrew reinstall of python (thereby broken symlinks) and also a few "sudo pip install"s I had done earlier. Weizhong's tips were very helpful in fixing the issues without having to reinstall packages. I also had to do the following for the mixed permissions problem.

sudo chown -R my\_username lib/python2.7/site-packages
So there are many ways but one which worked for me is as follows since I already had my requirements.txt file freeze.

So delete old virtual environment with following command
use
`deactivate`
`cd ..`
`rm -r old_virtual_environment`

to install virtualenv python package with pip
use `pip install virtualenv`

then check if it's installed correctly
use `virtualenv --version`

jump to your project directory
use `cd project_directory`

now create new virtual environment inside project directory using following
use `virtualenv name_of_new_virtual_environment`

now activate newly created virtual environment
use `source name_of_new_virtual_environment/bin/activate`

now install all project dependencies using following command
use `pip install -r requirements.txt`