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: 
If this was caused by a `brew upgrade` that upgraded its Python, and you're ok with downgrading to the previous version, try `brew switch python [previous version]`, eg `brew switch python 3.6.5`. [From here.](https://apple.stackexchange.com/a/326608/43900)
I am sure I am late to the party but I want to say that the resolution of this problem is much simpler than discussed here.

You can easily regenerate the virtual environment without having to delete/edit anything. Assuming that your broken environment is called `env_to_fix` you can just to the following:

```
mkvirtualenv env_to_fix

```

This will regenerate the links and fix the environment without the need to dump the current status somewhere and restore it.