I have a code snippet, called 'test.pyx':
import numpy as np
cimport numpy as np
print(np.arange(10))
And then I wrote two setup.py
to compile them. The first one worked fine:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
import numpy as np
extensions = [
Extension('test', ['test.pyx'], include_dirs = [np.get_include()]),
]
setup(
ext_modules = cythonize(extensions)
)
And this one did not work (which is also from an example on http://docs.cython.org/src/reference/compilation.html):
from distutils.core import setup
from Cython.Build import cythonize
import numpy as np
setup(
ext_modules = cythonize('./test.pyx', include_path=[np.get_include()])
)
It says: ./test.c(346) : fatal error C1083: Cannot open include file: 'numpy/arrayobject.h': No such file or directory.
I am using Python 3.3 64-bit on Windows 64-bit, with WinSDK 7.1.
Linux The GNU C Compiler (gcc) is usually present, or easily available through the package system. On Ubuntu or Debian, for instance, it is part of the build-essential package. Next to a C compiler, Cython requires the Python header files.
The cimport statement is used in a definition or implementation file to gain access to names declared in another definition file. Its syntax exactly parallels that of the normal Python import statement. When pure python syntax is used, the same effect can be done by importing from special cython.
This is a Cython documentation bug, see also https://github.com/cython/cython/issues/1480
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With