<p>所以我在Cython Google组上找到了代码(<a href="https://groups.google.com/forum/?fromgroups#!searchin/cython-users/using$20scipy/cython-users/CF9GqYN1aPU/WKC-N9c6zpgJ" rel="nofollow noreferrer">https://groups.google.com/forum/?fromgroups#!searchin/cython-users/using$20scipy/cython-users/CF9GqYN1aPU/WKC-N9c6zpgJ</a>)</p>
<p>它将以下内容显示为导入:</p>
<pre><code>import pylab as PL
from scipy import integrate
from scipy import optimize
from scipy.integrate import odeint
import numpy as np
cimport numpy as np
cimport cython
</code></pre>
<p>这给了我信心我可以用SciPy编译。添加<code>cimport cython</code>语句时,收到以下编译错误:</p>
<pre><code>dvi.c:237:31: error: numpy/arrayobject.h: No such file or directory
dvi.c:238:31: error: numpy/ufuncobject.h: No such file or directory
</code></pre>
<p>好像有路径或目录问题。事实上我是对的,这个网站上有一篇文章(<a href="https://stackoverflow.com/questions/6525161/my-cython-code-parses-into-c-but-doesnt-compile-first-time-trying-to-use-exte">My Cython code parses into C, but doesn't compile. First time trying to use external C code</a>)</p>
<p>解决方案是在setup.py文件中添加以下内容:</p>
<pre><code>import numpy
...
Extension(..., include_dirs = [numpy.get_include(), ... ] )
</code></pre>
<p>W00t!</p>