问题
首先想安装scikit-learn库在mac终端显示顺利安装完成,但是测试的时候报错如下所示:
python
/opt/anaconda3/envs/dtc/bin/python /Users/chenfaquan/PycharmProjects/TimeSeries/data_create.py
Traceback (most recent call last):
File "/Users/chen/PycharmProjects/TimeSeries/data_create.py", line 2, in <module>
from sklearn.preprocessing import MinMaxScaler
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/sklearn/__init__.py", line 83, in <module>
from .base import clone
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/sklearn/base.py", line 19, in <module>
from .utils import _IS_32BIT
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/sklearn/utils/__init__.py", line 15, in <module>
from scipy.sparse import issparse
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/__init__.py", line 283, in <module>
from . import csgraph
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/csgraph/__init__.py", line 185, in <module>
from ._laplacian import laplacian
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/csgraph/_laplacian.py", line 7, in <module>
from scipy.sparse.linalg import LinearOperator
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/__init__.py", line 120, in <module>
from ._isolve import *
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/__init__.py", line 4, in <module>
from .iterative import *
File "/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/iterative.py", line 9, in <module>
from . import _iterative
ImportError: dlopen(/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/_iterative.cpython-38-darwin.so, 0x0002): Library not loaded: @rpath/liblapack.3.dylib
Referenced from: <BEFB6E07-597A-3758-A60B-141E8E215EF0> /opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/_iterative.cpython-38-darwin.so
Reason: tried: '/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/liblapack.3.dylib' (no such file), '/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/../../../../../../liblapack.3.dylib' (no such file), '/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/liblapack.3.dylib' (no such file), '/opt/anaconda3/envs/dtc/lib/python3.8/site-packages/scipy/sparse/linalg/_isolve/../../../../../../liblapack.3.dylib' (no such file), '/opt/anaconda3/envs/dtc/bin/../lib/liblapack.3.dylib' (no such file), '/opt/anaconda3/envs/dtc/bin/../lib/liblapack.3.dylib' (no such file), '/usr/local/lib/liblapack.3.dylib' (no such file), '/usr/lib/liblapack.3.dylib' (no such file, not in dyld cache)
Process finished with exit code 1
解决方法
- 在网上看到的解决方法有:在终端运行以下语句。
python
conda install -c conda-forge scikit-learn
尝试未果,依然报错。
- g改用pip3:依然失败。
- 降低版本,成功!
参考链接:m1 arm64安装scikit-learn 问题
目前安装的版本:
spicy == 1.9.0
scikit-learn == 1.1.2