首页 > 解决方案 > 无法在 Jupyter 笔记本中导入 Numpy(RuntimeError: Polyfit sanity test 发出警告,很可能是由于使用了有问题的 Accelerate 后端)

问题描述

我正在关注https://www.firstpythonnotebook.org/(我是使用 Jupyter 的初学者,通常使用 python、pip 等)。基本上我到目前为止所遵循的步骤是:

  1. 安装 pipenv,在所需目录中创建新环境
  2. pipenv install jupyterlab
  3. pipenv install pandas在这个页面上

import pandas但是,当打开我的第一个笔记本并numpy运行pandas.

import pandas
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-1-38d4b0363d82> in <module>
----> 1 import pandas

~/.local/share/virtualenvs/test-notebook-again-duPr9W-R/lib/python3.9/site-packages/pandas/__init__.py in <module>
      9 for dependency in hard_dependencies:
     10     try:
---> 11         __import__(dependency)
     12     except ImportError as e:
     13         missing_dependencies.append(f"{dependency}: {e}")

~/.local/share/virtualenvs/test-notebook-again-duPr9W-R/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

我相信在安装 pandas 时默认会在环境中安装 Numpy,但是这个安装似乎出了点问题?我不知道“Accelerate”或“Polyfit”是什么,老实说,试图阅读它们是什么感觉就像我在头上一样。这里一定有一个比作为一个初学者来理解这些东西更简单的解决方案,对吧?任何人都知道为什么会发生这种情况?

标签: pythonpython-3.xpandasnumpyjupyter-notebook

解决方案


在我的 Mac 上工作就像一个魅力。

https://gist.github.com/yatsu/47bdde35e8abbe7d14bbe730342aa9e0

Numpy 1.19.2 和 Python 3.9.0


推荐阅读