[英]Numpy import error "undefined symbol: PyFPE_jbuf" on RPi
I'm attempting to install TensorFlow on my Raspberry Pi but numpy is having trouble working.我正在尝试在我的 Raspberry Pi 上安装 TensorFlow,但 numpy 无法正常工作。
My RPi installation is fresh from the microSD.我的 RPi 安装是全新的 microSD。 I am running Raspbian Buster and have not done anything prior on this system other than
sudo apt update && sudo apt upgrade
, install python3.5, and try to install the TensorFlow wheel file (the very last one) using python -m pip install <tensorflow>.whl
.我运行Raspbian巴斯特比其他在这个系统上之前没有做过任何
sudo apt update && sudo apt upgrade
,安装python3.5,并尝试安装TensorFlow轮文件使用(的最后一个) python -m pip install <tensorflow>.whl
。
I am using a clean virtualenv and pip to install python packages (both pip install ...
and python -m pip install ...
while in the env).我正在使用干净的 virtualenv 和 pip 来安装 python 包(
pip install ...
和python -m pip install ...
在 env 中)。 The installations have no errors or warnings;安装没有错误或警告; things look fine until I try to use/import numpy.
事情看起来很好,直到我尝试使用/导入 numpy。
The error referred to in the title is as follows:标题中提到的错误如下:
Python 3.5.4 (default, Sep 5 2017, 18:32:10)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pi/tensorflow/lib/python3.5/site-packages/numpy/__init__.py", line 152, in <module>
from . import random
File "/home/pi/tensorflow/lib/python3.5/site-packages/numpy/random/__init__.py", line 181, in <module>
from . import _pickle
File "/home/pi/tensorflow/lib/python3.5/site-packages/numpy/random/_pickle.py", line 1, in <module>
from .mtrand import RandomState
ImportError: /home/pi/tensorflow/lib/python3.5/site-packages/numpy/random/mtrand.cpython-35m-arm-linux-gnueabihf.so: undefined symbol: PyFPE_jbuf
I can consistently reproduce this by starting a clean virtualenv using python3.5, pip install numpy
or python -m pip ...
, then trying to import numpy like above.我可以通过使用 python3.5、
pip install numpy
或python -m pip ...
启动一个干净的 virtualenv 来始终如一地重现这一点,然后尝试像上面一样导入 numpy。
Most of the other questions I have seen pertaining to this have to do with cython installation paths or having another numpy on the computer, so this is what I have done so far:我看到的与此相关的大多数其他问题都与 cython 安装路径或在计算机上有另一个 numpy 有关,所以这就是我到目前为止所做的:
Uninstalled the default numpy installation on the pi卸载了pi上默认的numpy安装
Installed cython, reinstalled numpy安装cython,重新安装numpy
Installing numpy with pip install --no-cache-dir numpy
使用
pip install --no-cache-dir numpy
numpy installation works on a python3.7 virtualenv numpy 安装适用于 python3.7 virtualenv
I followed phd's comment and tried to build from source ( git clone ...
, cd numpy
, python setup.py
all in the virtualenv on python3.5).我按照 phd 的评论并尝试从源代码构建(
git clone ...
、 cd numpy
、 python setup.py
都在 python3.5 上的 virtualenv 中)。 This led to the same missing symbol, though in a different place.这导致了相同的丢失符号,尽管在不同的地方。 It looks Cython related?
它看起来与 Cython 相关?
Running from numpy source directory.
Cythonizing sources
Processing numpy/random/bounded_integers.pxd.in
Processing numpy/random/bounded_integers.pyx.in
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/pi/tensorflow/lib/python3.5/site-packages/cython.py", line 17, in <module>
main(command_line = 1)
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Main.py", line 858, in main
result = compile(sources, options)
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Main.py", line 780, in compile
return compile_multiple(source, options)
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Main.py", line 750, in compile_multiple
context = options.create_context()
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Main.py", line 597, in create_context
self.cplus, self.language_level, options=self)
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Main.py", line 80, in __init__
from . import Builtin, CythonScope
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/CythonScope.py", line 5, in <module>
from .UtilityCode import CythonUtilityCode
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/UtilityCode.py", line 3, in <module>
from .TreeFragment import parse_from_strings, StringParseContext
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/TreeFragment.py", line 17, in <module>
from .Visitor import VisitorTransform
File "Cython/Compiler/Visitor.py", line 17, in init Cython.Compiler.Visitor
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/ExprNodes.py", line 4724, in <module>
class SliceIndexNode(ExprNode):
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/ExprNodes.py", line 4922, in SliceIndexNode
"SliceObject", "ObjectHandling.c", context={'access': 'Get'})
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Code.py", line 404, in load
return cls(**kwargs)
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Code.py", line 648, in __init__
proto = sub_tempita(proto, context, file, name)
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Compiler/Code.py", line 640, in sub_tempita
from ..Tempita import sub
File "/home/pi/tensorflow/lib/python3.5/site-packages/Cython/Tempita/__init__.py", line 4, in <module>
from ._tempita import *
ImportError: /home/pi/tensorflow/lib/python3.5/site-packages/Cython/Tempita/_tempita.cpython-35m-arm-linux-gnueabihf.so: undefined symbol: PyFPE_jbuf
After this it just tells me that running cythonize failed in setup.py.在此之后,它只是告诉我在 setup.py 中运行 cythonize 失败。
You need to compile numpy
from the source.您需要从源代码编译
numpy
。 Get numpy
1.18.5
:获取
numpy
1.18.5
:
wget https://github.com/numpy/numpy/archive/refs/tags/v1.18.5.tar.gz
Uninstall the current Python 3.5
's numpy
and install cython
module:卸载当前
Python 3.5
的numpy
并安装cython
模块:
pip3.5 uninstall numpy
pip3.5 install cython==0.29.22
Change directory to numpy 1.18.5
's source code, install it:将目录更改为
numpy 1.18.5
的源代码,安装它:
python3.5 setup.py install
Once finished, your code will be able to successfully run import numpy
完成后,您的代码将能够成功运行
import numpy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.