首页 > 解决方案 > numpy 无法在 Big Sur 11.4 上运行

问题描述

最近,我的 Python 安装中的 Numpy 停止工作。

我相信这可能是由于我的 Mac 升级到 Xcode 12.5.1(于 2021 年 6 月 23 日更新)引起的。

这是我得到的错误:

Python 3.9.5 (default, May  4 2021, 03:36:27) 
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/numpy/core/__init__.py", line 22, in <module>
    from . import multiarray
  File "/usr/local/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in <module>
    from . import overrides
  File "/usr/local/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: dlopen(/usr/local/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): Symbol not found: ___addtf3
  Referenced from: /usr/local/lib/python3.9/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib
  Expected in: /usr/lib/libSystem.B.dylib
 in /usr/local/lib/python3.9/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/numpy/__init__.py", line 150, in <module>
    from . import core
  File "/usr/local/lib/python3.9/site-packages/numpy/core/__init__.py", line 48, in <module>
    raise ImportError(msg)
ImportError: 

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.9 from "/usr/local/opt/python@3.9/bin/python3.9"
  * The NumPy version is: "1.21.0"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/usr/local/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so, 2): Symbol not found: ___addtf3
  Referenced from: /usr/local/lib/python3.9/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib
  Expected in: /usr/lib/libSystem.B.dylib
 in /usr/local/lib/python3.9/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib

我的系统上不再有 /usr/lib/libSystem.B.dylib:

ls: /usr/lib/libSystem.B.dylib: No such file or directory

然而,似乎是大苏尔的预期。到目前为止,我似乎是唯一一个受到 numpy 影响的人……这是为什么呢?

我尝试从 pip3(源和轮子)和 brew 重新安装 numpy,但结果始终相同。

这是我的系统:

ProductName:    macOS
ProductVersion: 11.4
BuildVersion:   20F71

标签: pythonpython-3.xmacosnumpy

解决方案


我的类似错误已通过删除 Kite 得到修复。出于某种原因,应用程序在导入 numpy 时会导致问题。


推荐阅读