首页 > 解决方案 > 即使我安装了 pip3 也无法导入 NumPy

问题描述

这是我尝试导入它时得到的

>>> import numpy

Python(26024,0x11da32dc0) malloc: can't allocate region
:*** mach_vm_map(size=18446744071675105280, flags: 100) failed (error code=3)
Python(26024,0x11da32dc0) 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 "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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

以下是您可能想知道的其他信息。

  1. 我安装了numpy.

    eric@Erics-MacBook-Pro ~ % pip3 install numpy

    已满足要求:numpy in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (1.19.2)

  2. 我最近删除了oh-my-zsh但没有完全删除,所以当我打开终端时总是会出现这种情况。

    Last login: Tue Oct 6 17:57:22 on ttys002 /Users/eric/.zshrc:source:73: no such file or directory: /Users/eric/.oh-my-zsh/oh-my-zsh.sh

如果您需要什么,请告诉我。

标签: python-3.xnumpyimport

解决方案


我在尝试导入时遇到了完全相同的问题pandas(这需要numpy)。基本上Python 3.9不能很好地numpy在 macOS 上运行,原因很奇怪。降级到Python 3.8,一切正常:https ://www.python.org/downloads/release/python-386/ 。


推荐阅读