python - Cython memoryviews on Windows -


when trying use cython on windows (anaconda-based install, using tdm-gcc need support openmp), ran error when using typed memoryviews.

test1.pyx def test(int x): pass  test2.pyx def test(int[:] x): pass 

both modules can compiled basic setup.py (using cythonize), while test1 can imported no problem, importing test2 raises following:

python3 -c "import test2" (<- note use of python3 -- haven't tried python2) traceback (most recent call last):   file "<string>", line 1, in <module>   file "stringsource", line 275, in init test2 (test2.c:13146) unicodedecodeerror: 'utf-8' codec can't decode byte in position 1: invalid start byte. 

with nothing special @ line 13146 of test.c, apparently.

is known issue? or doing wrong? welcome.

(crossposted cython-users)

clarifications:

  • again, please note using python 3 (in fact, bug doesn't appear python 2).
  • i using clean install conda environment, using python 3.4.1 , cython 0.20.1.
  • i using following setup.py.

    from distutils.core import setup; cython.build import cythonize setup(ext_modules=cythonize("test.pyx"))

but longer setup.py such 1 suggested saullo castro doesn't either.

bounty awarded saullo castro pointing out mingw-64bit not supported, though ended using different solution.

i using windows 7 64-bit, python 2.7.5 64 bit , cython 0.20.1 , code works me.

i tested original code , this:

def test(int[:] x):     s = np.shape(x)[0]     in range(s):         print x[i] 

without problems. describe here how compiled cython , how configured c compiler use cython hope can solve problem following these steps.

set distutils_use_sdk=1 setenv /x64 /release 
  • compile cython (simply doing python setup.py should work)

  • have nice setup.py .pyx files, here follows sample use enable support openmp:

from distutils.core import setup distutils.extension import extension 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) 
  • use import pyximport; pyximport.install() when applicable

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -