3-manifolds / Sage_macOS

SageMath as a macOS application bundle.
152 stars 15 forks source link

SageMath-9-7 import error related to SciPy on Apple M1 Max #49

Closed hirani closed 1 year ago

hirani commented 1 year ago

In SageMath-9-7, importing scipy.special on an Apple M1 Max running MacOS Monterrey 12.6.1 caused an ImportError. Here is the traceback:

sage: import scipy.special
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 import scipy.special

File /private/var/tmp/sage-9.7-current/local/var/lib/sage/venv-python3.10.5/lib/python3.10/site-packages/scipy/special/__init__.py:652, in <module>
    649 from . import _ufuncs
    650 from ._ufuncs import *
--> 652 from . import _basic
    653 from ._basic import *
    655 from ._logsumexp import logsumexp, softmax, log_softmax

File /private/var/tmp/sage-9.7-current/local/var/lib/sage/venv-python3.10.5/lib/python3.10/site-packages/scipy/special/_basic.py:15, in <module>
     11 from . import _ufuncs as ufuncs
     12 from ._ufuncs import (mathieu_a, mathieu_b, iv, jv, gamma,
     13                       psi, hankel1, hankel2, yv, kv, ndtri,
     14                       poch, binom, hyp0f1)
---> 15 from . import _specfun
     16 from . import _orthogonal
     17 from ._comb import _comb_int

ImportError: dlopen(/private/var/tmp/sage-9.7-current/local/var/lib/sage/venv-python3.10.5/lib/python3.10/site-packages/scipy/special/_specfun.cpython-310-darwin.so, 0x0002): Library not loaded: '@rpath/libgfortran.5.dylib'
  Referenced from: '/Applications/SageMath-9-7.app/Contents/Frameworks/Sage.framework/Versions/9.7/local/var/lib/sage/venv-python3.10.5/lib/python3.10/site-packages/scipy/special/_specfun.cpython-310-darwin.so'
  Reason: tried: '/Applications/SageMath-9-7.app/Contents/Frameworks/Sage.framework/Versions/9.7/local/var/lib/sage/venv-python3.10.5/lib/python3.10/site-packages/scipy/special/libgfortran.5.dylib' (no such file), '/Applications/SageMath-9-7.app/Contents/Frameworks/Sage.framework/Versions/9.7/local/var/lib/sage/venv-python3.10.5/lib/python3.10/site-packages/scipy/special/libgfortran.5.dylib' (no such file), '/Applications/SageMath-9-7.app/Contents/Frameworks/Sage.framework/Versions/9.7/local/var/lib/sage/venv-python3.10.5/bin/../lib/libgfortran.5.dylib' (no such file), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file)
culler commented 1 year ago

I was not able to reproduce this on the Intel app and will not have access to the M1 app for a few days. The error message indicates that the _specfun module does not have its rpath set correctly on your system. Please make sure you have installed the latest version of SageMath-9-7.app. If so, please run: cd Applications/SageMath-9-7.app/Contents/Frameworks/Sage.framework/Versions/9.7/venv/lib/python3.10/site-packages/scipy/special Then run otool - l _specfun.cpython-310-darwin.so | grep path and report the result.

hirani commented 1 year ago

@culler Here is the relevant output of otool:

$ otool -l _specfun.cpython-310-darwin.so | grep path
         name @rpath/libgfortran.5.dylib (offset 24)
         name @rpath/libquadmath.0.dylib (offset 24)
         path @loader_path (offset 12)
culler commented 1 year ago

Thank you. That confirms my theory. No rpath is set.

On Sat, Nov 19, 2022, 9:42 AM Anil N. Hirani @.***> wrote:

@culler https://github.com/culler Here is the relevant output of otool:

$ otool -l _specfun.cpython-310-darwin.so | grep path name @rpath/libgfortran.5.dylib (offset 24) name @rpath/libquadmath.0.dylib (offset 24) path @loader_path (offset 12)

— Reply to this email directly, view it on GitHub https://github.com/3-manifolds/Sage_macOS/issues/49#issuecomment-1320921545, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ6CP2NX5CLZ4M6P6AKRO3WJD7ONANCNFSM6AAAAAASE45PSE . You are receiving this because you were mentioned.Message ID: @.***>

culler commented 1 year ago

@hirani would you please test the new diskimage in the v1.5.2 prerelease? Please let me know if it fixes this problem. Thanks.

hirani commented 1 year ago

@culler I tested the v1.5.2 prerelease and the problem is fixed. Thanks.

culler commented 1 year ago

Great. Thanks for the report.