本人系统为MacOS catalina 10.15.7
新的MacBook pro 用brew install python 安装了python,自动为3.9.0版本。然后pip3 install notebook,安装了jupyter noteboook。随后pip3 install numpy,打开notebook,出现“RankWarning: Polyfit may be poorly conditioned“ 错误。
import numpy as np
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-0aa0b027fcb6> in <module>
----> 1 import numpy as np
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/__init__.py in <module>
284 "that provided NumPy.\n{}\n".format(
285 error_message))
--> 286 raise RuntimeError(msg)
287 del _mac_os_check
288
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
查了一圈儿,发现是因为我的python 版本太高3.9的问题,回滚到3.8就没问题了。因此卸载了python 3.9 ,使用mac自带的python 3.8 重新安装即可。
注意,python3.9的卸载需要卸载完全,包括依赖包和软链接接,都要卸载干净。具体过程见本人文章 如何彻底卸载mac上的python 3.9
安装numpy
在mac默认的(或者自己重新装的)python 3.8的环境下安装numpy:
$ pip3 install numpy
Collecting numpy
Downloading https://files.pythonhosted.org/packages/33/1a/d10d1c23d21c289a3e87e751a9daf0907e91665cab08d0c35033fd4f5b55/numpy-1.19.2-cp38-cp38-macosx_10_9_x86_64.whl (15.3MB)
|████████████████████████████████| 15.3MB 12.1MB/s
Installing collected packages: numpy
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/3.8'
Consider using the `--user` option or check the permissions.
出现权限问题
改用root权限安装
$sudo pip3 install numpy
Password:
.......
https://files.pythonhosted.org/packages/33/1a/d10d1c23d21c289a3e87e751a9daf0907e91665cab08d0c35033fd4f5b55/numpy-1.19.2-cp38-cp38-macosx_10_9_x86_64.whl (15.3MB)
|████████████████████████████████| 15.3MB 414kB/s
Installing collected packages: numpy
Successfully installed numpy-1.19.2
安装成功
还可以使用pip3 install numpy --user
也可。这种安装只能登陆的账户使用。