【环境搭建】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
相关推荐
山川而川-R1 分钟前
ubuntu22.04安装PaddleX3
python·ocr
编程百晓君15 分钟前
2024最新教程Mac安装双系统
macos
慎思知行20 分钟前
Mac提示:安装anycast后台服务进程失败
macos
Stark-C23 分钟前
生产力利器,Mac 系统优选,keychron K10Max 三模键盘体验分享
macos·计算机外设
从以前43 分钟前
【算法题解】Bindian 山丘信号问题(E. Bindian Signaling)
开发语言·python·算法
海绵波波1071 小时前
flask后端开发(9):ORM模型外键+迁移ORM模型
后端·python·flask
余生H1 小时前
前端Python应用指南(二)深入Flask:理解Flask的应用结构与模块化设计
前端·后端·python·flask·全栈
CriticalThinking1 小时前
Pycharm不正常识别包含中文路径的解释器
ide·python·pycharm
sin22012 小时前
springboot数据校验报错
spring boot·后端·python