Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

macOS Big Sur python3 cannot import numpy due to polyfit error

update from Jan 2021: I performed a clean install of Big Sur in Jan 2021, and upgrade pip to latest version using python3 -m pip install --upgrade pip --user, and installed numpy without issues, and without the error message below.

original question from Nov 2020

I'm using macOS big sur on 2019 macbook pro. I'm able to install numpy using python3 -m pip install numpy --user. Note I do not have brew; I'm just using the python3 from the Xcode command line tools. I've seen this error reported in many other places, but they all seem to use brew.

However, when I try to import numpy as np, I get the following error messsage.

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
like image 435
xdavidliu Avatar asked Dec 30 '22 19:12

xdavidliu


1 Answers

The numpy installed by default in my question (and which caused the crash) was 1.19. I was able to use numpy with the following workaround:

python3 -m pip uninstall numpy
python3 -m pip install numpy==1.18.0 --user
like image 115
xdavidliu Avatar answered Jan 13 '23 20:01

xdavidliu