0

This issue is apparently well known and widely referenced. I'm running a python code using a conda installed environment on OSX. I'm getting

ImportError: dlopen(/Users/me/anaconda/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): Library not loaded: @rpath/libgfortran.3.dylib

This happens regardless of whether I install gcc in the environment. All the suggested work arounds I found aren't applicable to my case. It's been hours of googling.

Can someone please provide relevant suggestion to get over this hump?

Red
  • 6,599
  • 9
  • 43
  • 85
bhomass
  • 3,414
  • 8
  • 45
  • 75
  • 1
    Please tell us *how* and *where* did you install GCC, whether it was a full build of gcc including Fortran and also which workarounds did you try? What kind of code is causing the error? – Vladimir F Героям слава May 14 '18 at 05:14
  • I installed gcc on the mac before. don't remember how (can I find out with some command?). Just now I tried using conda install -c anaconda gcc. I am running sample jupyter notebook code https://github.com/fastai/courses/blob/master/deeplearning2/neural-style.ipynb and the error is as shown in my first post. – bhomass May 16 '18 at 00:22
  • But does your GCC include Fortran? Which version of gfortran it it? – Vladimir F Героям слава May 16 '18 at 05:58
  • when I do a locate fortran, I see instances of it all over the place. in /Applications/Octave.app, /Library/Frameworks/Python.framework, /System/Library/Frameworks/Python.framework, all of my conda envs, ~/macports, /user/local/Cellar/gcc, /userlocal/bin. /usr/local/lib/pythonxx/site-packages. gcc itself is from /usr/bin. Does this point out where I am at? – bhomass May 18 '18 at 20:28
  • Do you have `libgfortran.3.dylib`? Can you execute `gfortran -v`? What does it return when you execute it? – Vladimir F Героям слава May 18 '18 at 21:04
  • yes it returns gcc version 7.3.0 (Homebrew GCC 7.3.0). The executable is at /usr/local/bin/gfortran – bhomass May 19 '18 at 23:53

1 Answers1

2

Your gfortran is too new for your version of Python. Your Python requires libgfortran version 3, but GCC 7 has libgfortran version 4. You will have to install GCC version 6 or older.

See a similar issue on Linux R v3.4.0-2 unable to find libgfortran.so.3 on Arch

  • you are prob right. I already upgrade to python 3 and this problem went away. – bhomass May 31 '18 at 04:50
  • could you help out again. I have to run both python 2 and 3 on my mac. How do I get python2 to find the older version of gfortran (4.9) when the default path points to version 7? – bhomass Jul 04 '18 at 01:35
  • Hard to say without your configuration. You could ask a new question. Does OSX use LD_LIBRARY_PATH or LD_PRELOAD or similar? Where are the GCC versions installed? Which exact errors you got now? We can't solve that here. – Vladimir F Героям слава Jul 04 '18 at 06:22