zsh*_*zsh 33 macos numpy python-3.x
我正在使用运行 Big Sur 11.1 的 MacBook m1,并且我已经安装了Xcode-commandline-tools12.3 版并且它已经安装python3.8.5并且pip3.python3 和 pip 是本机应用程序,即它们在 ARM 中运行
pip3 版本 20.3.3
python3 版本 3.8.5
setuptools 版本 51.0.0
wheel 版本 0.36.2
当我打字时 python3 -m pip install numpy
输出是:
Defaulting to user installation because normal site-packages is not writeable
Collecting numpy
Using cached numpy-1.19.4.zip (7.3 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'done'
Building wheels for collected packages: numpy
Building wheel for numpy (PEP 517): started
sandeep@Sandeeps-Air ~ % cat a
Defaulting to user installation because normal site-packages is not writeable
Collecting numpy
Using cached numpy-1.19.4.zip (7.3 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: finished with status 'done'
Building wheels for collected packages: numpy
Building wheel for numpy (PEP 517): started
Building wheel for numpy (PEP 517): finished with status 'error'
Failed to build numpy
Run Code Online (Sandbox Code Playgroud)
并且有一个非常大的错误列表
M1 仍然不支持 numpy 还是我做错了?
Bar*_*ard 43
I had exactly the same issue with my brand new Mac Mini. After spending an afternoon reading this issue on github, I finally succeeded. However, it only seems to work with v1.20.0rc2 or above...
Long story short, these were the steps I've taken to get it working:
pip3 install Cython
git clone https://github.com/numpy/numpy.git
cd numpy
pip3 install . --no-binary :all: --no-use-pep517
Run Code Online (Sandbox Code Playgroud)
After that, I could cd into my virtualenv and import numpy:
>>> import numpy as np
>>> np.__version__
'1.21.0.dev0+402.gc4ae3ce64'
>>>
Run Code Online (Sandbox Code Playgroud)
Next up: pandas.
UPDATE: After some more searching, I found this interesting article, which states that you can easily start Terminal in Rosatta mode. That also solved the issues.
However, I am working with a headless Mac Mini, so I still have to find out whether that solution also is feasable in that particular setup.
UPDATE 2
I now have pandas working as well, thanks to this answer on SO.
Mik*_*kin 14
是的,稳定版似乎仍然不支持 numpy,但是如果您准备使用不稳定版,请尝试以下命令:
pip3 安装 numpy --compile --pre
这将从不稳定分支重新编译所有必要的代码。
为我工作。
Gri*_*ang 12
从 NumPy 1.21.0 开始,它发布了适用于 Mac 上的 Python 3.8 和 Python 3.9 的universal2轮子。它可以安装在 Mac M1 上。
我已在 M1 上使用 Python 3.9.2、macOS Big Sur (11.5.1) 和 pip 21.1.3 对其进行了测试。只需使用pip/pip3它即可安装。
发行说明:https ://github.com/numpy/numpy/releases/tag/v1.21.0
请注意,目前(2021 年 2 月)M1 ARM 架构上完整的 Python 数据科学套件唯一可靠的构建环境是通过 miniforge。
例如
brew install --cask miniforge
conda init zsh
conda activate
conda install numpy scipy scikit-learn
Run Code Online (Sandbox Code Playgroud)
它对我有用的是在启用“使用 Rosetta 打开”选项的情况下运行 iTerm,并在安装 numpy 之前升级 pip。
除了启用此选项之外,您还可以运行pip install并使用 python 选择不同的体系结构arch -x86_64。使用虚拟环境的示例:
$ python3 -m venv ~/myenv
$ source ~/myenv/bin/activate
(myenv)$ python3 -m pip install --upgrade pip
Collecting pip
Using cached pip-21.0.1-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
Successfully installed pip-21.0.1
(myenv)$ arch -x86_64 pip install numpy
Collecting numpy
Using cached numpy-1.20.1-cp39-cp39-macosx_10_9_x86_64.whl (16.1 MB)
Installing collected packages: numpy
Successfully installed numpy-1.20.1
(myenv)$ arch -x86_64 python3
Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:44:01)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.__version__
'1.20.1'
Run Code Online (Sandbox Code Playgroud)
我试图在没有 Rosetta 2 的情况下安装 numpy,但这里列出的解决方案对我来说失败了。布鲁拯救了这一天。我安装了它
brew install numpy
Run Code Online (Sandbox Code Playgroud)