2

Fresh install of anaconda python3 onto secondary hard drive of mac running mavericks.

import sklearn

gives

Library not loaded: /usr/local/lib/libgcc_s.1.dylib
  Referenced from: /Volumes/SecondHD/anaconda/lib/python3.5/site-packages/scipy/sparse/linalg/isolve/_iterative.so
  Reason: image not found

gcc was installed with home-brew and exists.

which gcc

gives

/usr/bin/gcc

In /usr/local/Cellar/gcc/6.1.0/lib/gcc/6 I can find libgcc_s.1.dylib so I know it's there even tho it was not symlinked in /usr/local/lib.

Rather than adding more symlinks to /usr/local/lib from all the libraries in Cellar, I instead added the location of the libraries to the search path.

In my ~.profile I have

export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/Cellar/gcc/6.1.0/lib/gcc/6"

But that does not work. However, the error goes away if I add this line to my .profile

export DYLD_FALLBACK_LIBRARY_PATH=/usr/local/Cellar/gcc/6.1.0/lib/gcc/6

My understanding from this post is that LIBRARY_PATH is a list of places a compiler (like gcc) will look for libraries when it is linking code. But in Mac OSX, DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH contain a list of places any program will search for a shared library when it runs.

So if sklearn wants a gcc library, that would mean some compilation (and linking) will happen. Why is this line not sufficient

export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/Cellar/gcc/6.1.0/lib/gcc/6"

and why is DYLD_FALLBACK_LIBRARY_PATH or DYLD_LIBRARY_PATH needed?

Community
  • 1
  • 1
aquagremlin
  • 3,515
  • 2
  • 29
  • 51
  • do you have a libgcc in your environment? – cel Jul 20 '16 at 05:57
  • what do you mean 'environment'? I set the environment variable export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/Cellar/gcc/6.1.0/lib/gcc/6" In that folder is libgcc – aquagremlin Jul 20 '16 at 11:39

1 Answers1

2

I had the same problem. What I did was creating symbolic links from my cellar folder of gcc to /usr/local/lib.

  1. look for the right path of you gcc

  2. ln -s /usr/local/Cellar/gcc/X.X.X/lib/gcc/6/* /usr/local/lib

Fabio Fumarola
  • 430
  • 3
  • 9
  • Small comment - I don't have gcc through homebrew, but something about upgrading to Sierra broke some things in my installations; I just had to run `ln -s /usr/local/lib/gcc/6/lib* /usr/local/lib/` and now things work. Thanks! – dwanderson Feb 21 '17 at 19:00