When trying to use Cython on Windows (Anaconda-based install, using TDM-GCC as I need support for OpenMP), I ran into an error when using typed memoryviews.
test
I am using Windows 7 64-bit, Python 2.7.5 64 bit and Cython 0.20.1 and your code works for me.
I tested your original code and this:
def test(int[:] x):
s = np.shape(x)[0]
for i in range(s):
print x[i]
without problems. I will describe here how I compiled by Cython and how I configured my C compiler to use with Cython with the hope that you can solve your problem following these steps.
Download and Microsoft SDK C Compiler according to your Python version
Configure your compiling environment in Windows, for me it is:
SET DISTUTILS_USE_SDK=1
setenv /x64 /release
Compile Cython (simply doing python setup.py
should work)
Have a nice setup.py
for your .pyx
files, here it follows a sample that I use to enable support to OpenMP:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension('test1',
['test1.pyx'],
extra_compile_args=['/openmp', '/O2',
'/favor:INTEL64'])]
setup(name = 'test1',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules)
import pyximport; pyximport.install()
when applicable