MacOS上的Python导入错误:'import scipy.integrate'引发'库未加载:用于反式

mpgws1up  于 2022-11-23  发布在  Mac
关注(0)|答案(2)|浏览(235)

echo $PATH给出
/usr/local/texlive/2021/bin/universal-darwin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin
更新到MacOS后,Python中的Monterey import scipy.integrate会引发

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-f7ec28d1adc8> in <module>
----> 1 import scipy.integrate

/usr/local/lib/python3.9/site-packages/scipy/integrate/__init__.py in <module>
     88    solve_bvp     -- Solve a boundary value problem for a system of ODEs.
     89 """
---> 90 from ._quadrature import *
     91 from .odepack import *
     92 from .quadpack import *

/usr/local/lib/python3.9/site-packages/scipy/integrate/_quadrature.py in <module>
      8 # even though it's actually a NumPy function.
      9 from numpy import trapz
---> 10 from scipy.special import roots_legendre
     11 from scipy.special import gammaln
     12 

/usr/local/lib/python3.9/site-packages/scipy/special/__init__.py in <module>
    631 from .sf_error import SpecialFunctionWarning, SpecialFunctionError
    632 
--> 633 from . import _ufuncs
    634 from ._ufuncs import *
    635 

ImportError: dlopen(/usr/local/lib/python3.9/site-packages/scipy/special/_ufuncs.cpython-39-darwin.so, 0x0002): Library not loaded: /usr/local/opt/gcc/lib/gcc/10/libgfortran.5.dylib
  Referenced from: /usr/local/lib/python3.9/site-packages/scipy/special/_ufuncs.cpython-39-darwin.so
  Reason: tried: '/usr/local/opt/gcc/lib/gcc/10/libgfortran.5.dylib' (no such file), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file)

你知道吗?

anhgbhbe

anhgbhbe1#

根据错误信息,它无法在/usr/local/opt/gcc/lib/gcc/10中找到libgfortran.5.dylib。由于您使用的是gcc版本11,您可以尝试通过

mkdir -p /usr/local/opt/gcc/lib/gcc/10
cp /usr/local/opt/gcc/lib/gcc/11/libgfortran.5.dylib /usr/local/opt/gcc/lib/gcc/10/

在终端内部。

qfe3c7zg

qfe3c7zg2#

同样的事情发生在我身上,当我升级我的MacBook Pro到MacOs Ventura 13.0.1,scipy.stat没有加载.我通过更新conda修复了它

conda update conda

相关问题