Raspberry Pi上的Numpy导入错误Python3?

时间:2018-12-14 17:41:47

标签: python python-3.x numpy

当我尝试在Python3中导入numpy时,出现错误。
我是通过pip3安装的,安装成功。

sudo pip3 install numpy

这是我尝试导入numpy时的错误消息:

Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 16, in <module>
    from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

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.5/dist-packages/numpy/__init__.py", line 142, in <module>
    from . import add_newdocs
  File "/usr/local/lib/python3.5/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/local/lib/python3.5/dist-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/local/lib/python3.5/dist-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/local/lib/python3.5/dist-packages/numpy/core/__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory

2 个答案:

答案 0 :(得分:3)

我将添加一个答案,因为我没有足够的声誉来发表评论。

我在 Raspberry Pi 4 上遇到了这个问题。

就我而言,只需在命令行中运行即可解决此问题:

sudo apt-get install libatlas-base-dev

我最初以为我缺少 python 模块依赖项,但这是一个 unix 依赖项,它不应该影响您的 python 虚拟环境

答案 1 :(得分:2)

将我的评论移至答案,因为它对一些用户似乎很有帮助。

您缺少核心的numpy依赖项。正在运行

sudo apt-get install python-dev libatlas-base-dev

应该解决问题。

如果这不起作用,则可以尝试安装特定于RPi的numpy版本,请参阅注释here