Relink virtualenv python after upgrading Homebrew python

The link is sharp with brew cleanup

app: source venv/bin/activate
[venv] app: python
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /path/to/app/venv/bin/python
  Reason: image not found

Python 3.x series

** If you are using the venv directory inside the application directory **

find ./.venv -type l -delete && python3 -m venv ./.venv

Python 2.x series

** If you are using virtualenv **

Relink of the guy who became like. All you have to do is unlink the ʻenvdirectory and relink with thevirtualenv` command.

find ./venv -type l -delete && virtualenv ./venv

It's annoying to relink one by one. You can update all at once by using virtualenvwrapper as follows

workon | xargs -L 1 -t -P 4 -I % -- sh -c 'find $WORKON_HOME/% -type l -delete && virtualenv $WORKON_HOME/%'

Recommended Posts

Relink virtualenv python after upgrading Homebrew python
python in virtualenv
homebrew python environment construction
[Python] What is virtualenv
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Manage python environment with virtualenv
Homebrew Python --Youtube Search Program
Install pyenv from Homebrew, install Python from pyenv
[Python] virtualenv creation procedure memo
Specify python version with virtualenv
[Python] Anaconda, pyenv, virtualenv, .bash_profile
[Python] How to use virtualenv