简体   繁体   English

Cython:致命错误:未找到“numpy/arrayobject.h”文件,使用 numpy

[英]Cython: fatal error: 'numpy/arrayobject.h' file not found, using numpy

I am trying to move my Ipython notebook code to python.我正在尝试将我的 Ipython 笔记本代码移动到 python。 But I have the error但我有错误

fatal error: 'numpy/arrayobject.h' file not found
#include "numpy/arrayobject.h"

, even though I have included numpy in the setup ,即使我在设置中包含了 numpy

My setup.py:我的 setup.py:

from distutils.core import setup, Extension
from Cython.Build import cythonize
import numpy

setup(
    ext_modules=cythonize("Trajectory.pyx"),
    include_dirs=[numpy.get_include()]
)

the Trajectory.pyx file Trajectory.pyx 文件

cimport numpy as np
import  numpy as np 

I am running on osX, Python 2.7.10我在 osX、Python 2.7.10 上运行

It also gives me this information before the error, hope this help identifying the issue: clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c Trajectory.c -o build/temp.macosx-10.11-x86_64-2.7/Trajectory.o它还在错误之前为我提供了此信息,希望这有助于确定问题:clang -fno-strict-aliasing -fno-common -dynamic -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer /SDKs/MacOSX10.11.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5 /Headers -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I /usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c Trajectory.c -o build/temp.macosx-10.11-x86_64-2.7/Trajectory.o

And when I ran当我跑

import numpy
numpy.get_include()

I get:我得到:

'/usr/local/lib/python2.7/site-packages/numpy/core/include'

And I look into the directory, /numpy/arrayobject.h is there.我查看目录,/numpy/arrayobject.h 在那里。 So I really don't know why it said no such a file所以我真的不知道为什么它说没有这样的文件

FWIW, I ran into the same issue ( 'numpy/arrayobject.h' file not found ) on macOS (Python 3.7.6, Cython 0.29.14, macOS 10.15). FWIW,我在 macOS(Python 3.7.6、Cython 0.29.14、macOS 10.15)上遇到了同样的问题( 'numpy/arrayobject.h' file not found )。

This is the workaround I used to get the include path right:这是我用来正确获取包含路径的解决方法:

from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import numpy

setup(name='Foo',
      ext_modules=cythonize([Extension("bar", ["bar.pyx"], include_dirs=[numpy.get_include()])])
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Cython:“致命错误:numpy/arrayobject.h:没有这样的文件或目录” - Cython: "fatal error: numpy/arrayobject.h: No such file or directory" cimport给出致命错误:找不到“ numpy / arrayobject.h”文件 - cimport gives fatal error: 'numpy/arrayobject.h' file not found 致命错误:numpy/arrayobject.h:google colab 中没有这样的文件或目录#include“numpy/arrayobject.h” - fatal error: numpy/arrayobject.h: No such file or directory #include "numpy/arrayobject.h" in google colab 致命错误:numpy / arrayobject.h:没有这样的文件或目录 - fatal error: numpy/arrayobject.h: No such file or directory 致命错误:使用 pyenv 时找不到“arrayobject.h”文件 - fatal error: 'arrayobject.h' file not found when using pyenv 如何解决这个致命错误:numpy/arrayobject.h:没有这样的文件或目录? - How do I resolve this make fatal error: numpy/arrayobject.h: No such file or directory? 相当于使用#include <Numeric/arrayobject.h> 在Numpy - equivalent of using #include <Numeric/arrayobject.h> in Numpy 编译.pyx文件时缺少numpy / arrayobject.h - Missing numpy/arrayobject.h while compiling .pyx file 如何使用C将数据从np.array获取到std :: vector <numpy/arrayobject.h> ? - How to get data from np.array to std::vector in c++ using <numpy/arrayobject.h>? 将 numpy 的 arrayobject.h 包含到 bitbake 配方中 - 如何修复安装顺序? - Include numpy's arrayobject.h into bitbake recipe - how to fix installation order?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM