【环境搭建】MAC M3-MAX芯片安装scikit-learn库报错。

问题

首先想安装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

解决方法

  1. 在网上看到的解决方法有:在终端运行以下语句。
python 复制代码
conda install -c conda-forge scikit-learn

尝试未果,依然报错。

参考链接:MAC M1安装scikit-learn库

  1. g改用pip3:依然失败。
  2. 降低版本,成功!
    参考链接:m1 arm64安装scikit-learn 问题
    目前安装的版本:
    spicy == 1.9.0
    scikit-learn == 1.1.2
相关推荐
凤枭香4 分钟前
Python OpenCV 傅里叶变换
开发语言·图像处理·python·opencv
测试杂货铺12 分钟前
外包干了2年,快要废了。。
自动化测试·软件测试·python·功能测试·测试工具·面试·职场和发展
HerayChen15 分钟前
HbuildderX运行到手机或模拟器的Android App基座识别不到设备 mac
android·macos·智能手机
艾派森16 分钟前
大数据分析案例-基于随机森林算法的智能手机价格预测模型
人工智能·python·随机森林·机器学习·数据挖掘
hairenjing112318 分钟前
在 Android 手机上从SD 卡恢复数据的 6 个有效应用程序
android·人工智能·windows·macos·智能手机
小码的头发丝、42 分钟前
Django中ListView 和 DetailView类的区别
数据库·python·django
Chef_Chen1 小时前
从0开始机器学习--Day17--神经网络反向传播作业
python·神经网络·机器学习
千澜空2 小时前
celery在django项目中实现并发任务和定时任务
python·django·celery·定时任务·异步任务
斯凯利.瑞恩2 小时前
Python决策树、随机森林、朴素贝叶斯、KNN(K-最近邻居)分类分析银行拉新活动挖掘潜在贷款客户附数据代码
python·决策树·随机森林
yannan201903132 小时前
【算法】(Python)动态规划
python·算法·动态规划