I use pipenv to create virtualenv like this

pipenv --python /usr/local/bin/python3

After upgrade python with Homebrew, like python 3.7.2 to 3.7.3, active virtualenv with pipenv shell, and do anything with python will be error like this

python3 --version
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /Users/xxx/.local/share/virtualenvs/xxx-xxx/bin/python3
  Reason: image not found
[1]    60198 abort      python3 --version

All I know about this is /usr/local/bin/python3 is still there, run python on system level is good. Only call python in virtualenv will be wrong.

For now I have remove the virtualenvs and create it with pipenv again, it will fix this. But do these things will lost all pip packages, so I need to reinstall them again.

So, dose there have some smart way to solve this problem? Or what is happen during Homebrew upgrade python?

Maybe this question looks stupid. But I have been confused for a long time.

Thanks in advance.

0 Answers