由于 polyfit 错误,macOS Big Sur python3 无法导入 numpy

xda*_*liu 4 python macos numpy xcode-command-line-tools macos-big-sur

2021 年 1 月的更新:我在2021 年 1 月执行了 Big Sur 的全新安装,并使用 将 pip 升级到最新版本python3 -m pip install --upgrade pip --user,并且安装numpy没有问题,并且没有下面的错误消息。

2020 年 11 月的原始问题

我在 2019 macbook pro 上使用 macOS big sur。我可以使用python3 -m pip install numpy --user. 注意我没有brew; 我只是使用 Xcode 命令行工具中的 python3。我在许多其他地方看到过这个错误报告,但他们似乎都使用 brew。

但是,当我尝试时import numpy as np,我收到以下错误消息。

Python(488,0x11700be00) malloc: can't allocate region
:*** mach_vm_map(size=18446744071565352960, flags: 100) failed (error code=3)
Python(488,0x11700be00) malloc: *** set a breakpoint in malloc_error_break to debug
init_dgelsd failed init
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/xdavidliu/Library/Python/3.8/lib/python/site-packages/numpy/__init__.py", line 286, in <module>
    raise RuntimeError(msg)
RuntimeError: Polyfit sanity test emitted a warning, most likely due to using a buggy Accelerate backend. If you compiled yourself, see site.cfg.example for information. Otherwise report this to the vendor that provided NumPy.
RankWarning: Polyfit may be poorly conditioned
Run Code Online (Sandbox Code Playgroud)

xda*_*liu 9

我的问题中默认安装的 numpy(并导致崩溃)是 1.19。我能够通过以下解决方法使用 numpy:

python3 -m pip uninstall numpy
python3 -m pip install numpy==1.18.0 --user
Run Code Online (Sandbox Code Playgroud)