Skip to content

Instantly share code, notes, and snippets.

@rxseger
Created June 20, 2016 03:46
Show Gist options
  • Save rxseger/a5759c74df6cb8183ea08afc383c0f16 to your computer and use it in GitHub Desktop.
Save rxseger/a5759c74df6cb8183ea08afc383c0f16 to your computer and use it in GitHub Desktop.
Fixing 'ImportError: dlopen(/usr/local/lib/python2.7/site-packages/scipy/fftpack/_fftpack.so, 2): Library not loaded: /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib' with scipy installed via homebrew
python /Users/admin/rf/gnuradio/gr-dtv/examples/atsc_ctrlport_monitor.py
python
import scipy
import scipy.fftpack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/scipy/fftpack/__init__.py", line 95, in <module>
from .basic import *
File "/usr/local/lib/python2.7/site-packages/scipy/fftpack/basic.py", line 12, in <module>
from . import _fftpack
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/scipy/fftpack/_fftpack.so, 2): Library not loaded: /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/scipy/fftpack/_fftpack.so
Reason: image not found
scipy installed from: brew install scipy
hint from https://github.com/Homebrew/homebrew-science/issues/3718 - caused by gcc 5 -> 6
library is linking gcc/5, but we have gcc/6
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib /usr/local/lib/python2.7/site-packages/scipy/fftpack/_fftpack.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libquadmath.0.dylib /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib /usr/local/lib/python2.7/site-packages/scipy/fftpack/_fftpack.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib /usr/local/lib/python2.7/site-packages/scipy/fftpack/convolve.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libquadmath.0.dylib /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib /usr/local/lib/python2.7/site-packages/scipy/fftpack/convolve.so
repeat for other libraries as needed, after fixing, should be able to load:
$ python
>>> import scipy
>>> import scipy.fftpack
and run:
$ python /Users/admin/rf/gnuradio/gr-dtv/examples/atsc_ctrlport_monitor.py
Traceback (most recent call last):
File "/Users/admin/rf/gnuradio/gr-dtv/examples/atsc_ctrlport_monitor.py", line 147, in <module>
host = sys.argv[1]
IndexError: list index out of range
@rxseger
Copy link
Author

rxseger commented Jun 20, 2016

@rxseger
Copy link
Author

rxseger commented Jun 30, 2016

sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib /usr/local/lib/python2.7/site-packages/scipy/special/_ufuncs.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib /usr/local/lib/python2.7/site-packages/scipy/special/specfun.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libquadmath.0.dylib /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib /usr/local/lib/python2.7/site-packages/scipy/special/specfun.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib /usr/local/lib/python2.7/site-packages/scipy/linalg/_fblas.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libquadmath.0.dylib /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib /usr/local/lib/python2.7/site-packages/scipy/linalg/_fblas.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib /usr/local/lib/python2.7/site-packages/scipy/linalg/_flapack.so
sudo install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libquadmath.0.dylib /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib /usr/local/lib/python2.7/site-packages/scipy/linalg/_flapack.so

many more.. do all, based on https://github.com/Homebrew/homebrew-science/issues/3718#issuecomment-224997438

sudo -s
find /usr/local/lib/python2.7/site-packages/scipy -name '*.so' | xargs -L1 install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libquadmath.0.dylib /usr/local/opt/gcc/lib/gcc/6/libquadmath.0.dylib
find /usr/local/lib/python2.7/site-packages/scipy -name '*.so' | xargs -L1 install_name_tool -change /usr/local/opt/gcc/lib/gcc/5/libgfortran.3.dylib /usr/local/opt/gcc/lib/gcc/6/libgfortran.3.dylib
exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment