更新:scikit-learn 现在通过 pip 工作✅
首先是brew install openblas - 它有针对不同处理器的指令 (wikipedia)
brew install openblas
export OPENBLAS=$(/opt/homebrew/bin/brew --prefix openblas)
export CFLAGS="-falign-functions=8 ${CFLAGS}"
# ^ no need to add to .zshrc, just doing this once.
pip install scikit-learn # ==0.24.1 if you want
在 M1 Pro 上表现出色 ?
额外细节
Pip 从 Pipy 下载源代码,然后针对 MacOS X 12.0 和 arm64(苹果硅)构建了轮子:scikit_learn-1.0.1-cp38-cp38-macosx_12_0_arm64.whl。
Building wheels for collected packages: scikit-learn
Building wheel for scikit-learn (pyproject.toml) ... done
Created wheel for scikit-learn: filename=scikit_learn-1.0.1-cp38-cp38-macosx_12_0_arm64.whl size=6364030 sha256=0b0cc9a21af775e0c8077ee71698ff62da05ab62efc914c5c15cd4bf97867b31
Successfully built scikit-learn
Installing collected packages: scipy, scikit-learn
Successfully installed scikit-learn-1.0.1 scipy-1.7.3
关于 Pipy 的注意事项:我们通常会下载 预构建的轮子(是的,这对于可靠的分发和确保兼容性非常有用)。或者,如果不存在预构建的轮子(悲伤),那么我们下载 tar.gz 并自己构建它。发生这种情况是因为作者没有向 Pipy 发布预构建的轮子,但是越来越多的人将其添加到他们的 CI(github 操作)工作流程中。自己构建轮子需要更多的 cpu 时间,并且通常不太可靠,但在这种情况下可以工作。
我们在这里下载了一个预构建的轮子,它几乎没有限制:它适用于任何版本的 python 3、任何操作系统、任何架构(如 amd64 或 arm64):click-8.0.3-py3-none-any.whl
Collecting click>=7.0
Downloading click-8.0.3-py3-none-any.whl
这里显然我们没有可用的轮子,所以我们必须使用setuptools 运行setup.py 自己构建它。
Collecting grpcio>=1.28.1
Downloading grpcio-1.42.0.tar.gz (21.3 MB)
|████████████████████████████████| 21.3 MB 12.7 MB/s
Preparing metadata (setup.py) ... done
## later in the process it installs using setuptools
Running setup.py install for grpcio ... done
祝你好运和快乐的管道。