Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew broken link to Python in a virtualenv

I recently ran (OS X 10.6.8) brew update and brew upgradeand am working in a virtualenv that now fails. I've tried:

$ brew unlink python && brew link python
Unlinking /usr/local/Cellar/python/2.7.8_1... 38 symlinks removed
Linking /usr/local/Cellar/python/2.7.8_1... 35 symlinks created

But in the virtualenv, I still get this:

$ python --version
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /Users/admin/.virtualenvs/saves/bin/python
  Reason: image not found
Trace/BPT trap

I've found another post on this, but the solution still seems unclear. I'm in a hurry, so uninstalled the Python version and ran brew doctor which returned the error above as a warning:

sh: line 1: 40991 Trace/BPT trap          python -V 2>&1

Then brew install python. Still getting the above error in the virtualenv.

Related questions and a post on debugfix aren't definitive:

Broken references in Virtualenvs
dyld-library-loaded-executable_path-python

Update

Creating a new virtualenv solved this specific problem.

like image 452
Dave Everitt Avatar asked Sep 25 '14 08:09

Dave Everitt


1 Answers

Use something like this:

find <virtualenv> -type l -delete
virtualenv -p $(which python3) <virtualenv>

All of the symlinks are broken, so it's necessary to delete them. When you recreate the virtualenv it recreates the symlinks while keeping installed packages.

Note: Replace $(which python3) with location of whatever python version you want to use.

like image 137
drice304 Avatar answered Oct 08 '22 11:10

drice304