Type error

64 views
Skip to first unread message

Pedro Camargo

unread,
May 18, 2013, 8:33:36 PM5/18/13
to cython...@googlegroups.com

Hi guys,

                  I’m working on a fairly long code that is compiling correctly, but giving an error when it runs.

 

                I’m working on Windows 64 bits, Python 2.7 (last installer made available) and the last versions of the installers for Numpy/Scipy/Cython  made by Chris Gohlke.

 

Thanks for the help,

               

Pedro

 

The error is:

 

File "Assignment2.pyx", line 493, in Assignment._Ordering_and_Forward_Star (Assignment2.c:6242)

    cdef _Ordering_and_Forward_Star(np.ndarray[ITYPE_t, ndim=2, mode='c'] graph, #A_Node/B_Node

ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long long'

 

 

 

It points to this header:

 

cdef _Ordering_and_Forward_Star(np.ndarray[ITYPE_t, ndim=2, mode='c'] graph, #A_Node/B_Node

                    np.ndarray[ITYPE_t, ndim=2, mode='c'] g_aux,

                    np.ndarray[DTYPE_t, ndim=2, mode='c'] graph_data,

                    np.ndarray[DTYPE_t, ndim=2, mode='c'] g_aux2,

                    np.ndarray[ITYPE_t, ndim=1, mode='c'] ind,

                    np.ndarray[ITYPE_t, ndim=1, mode='c'] graph_fs):

 

 

And the matrices are dimensioned and the function called this way:

 

graph=np.zeros((l,2), dtype=ITYPE) #Holds node of origin and node of destination

graph_fs=np.zeros(nodes+1, dtype=ITYPE)  #Holds the Forward star for the graph

graph_data=np.zeros((l,2), dtype=DTYPE) #Holds data for the graph. First column is the nested utility and the second the utility used for Shortest path

g_aux=graph.copy() #to sort the indices

g_aux2=graph_data.copy()

 

_Ordering_and_Forward_Star(graph,

                               g_aux,

                               graph_data,

                               g_aux2,

                                ind,

                                graph_fs)

 

Searching the problem I saw references to a problem of 32 Vs. 64 bits, but when I tried with 32 bits I get this:

 

C:\Users\Pedro\Desktop\Paths test>c:\Python27\python setup_Assignment.py build_e

xt --inplace

running build_ext

skipping 'Assignment2.c' Cython extension (up-to-date)

building 'Assignment' extension

Traceback (most recent call last):

  File "setup_Assignment.py", line 23, in <module>

    include_dirs=[np.get_include()])

  File "c:\Python27\lib\distutils\core.py", line 152, in setup

    dist.run_commands()

  File "c:\Python27\lib\distutils\dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "c:\Python27\lib\distutils\dist.py", line 972, in run_command

    cmd_obj.run()

  File "c:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 163,

in run

    _build_ext.build_ext.run(self)

  File "c:\Python27\lib\distutils\command\build_ext.py", line 339, in run

    self.build_extensions()

  File "c:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 171,

in build_extensions

    self.build_extension(ext)

  File "c:\Python27\lib\distutils\command\build_ext.py", line 498, in build_exte

nsion

    depends=ext.depends)

  File "c:\Python27\lib\distutils\msvc9compiler.py", line 473, in compile

    self.initialize()

  File "c:\Python27\lib\distutils\msvc9compiler.py", line 383, in initialize

    vc_env = query_vcvarsall(VERSION, plat_spec)

  File "c:\Python27\lib\distutils\msvc9compiler.py", line 299, in query_vcvarsal

l

    raise ValueError(str(list(result.keys())))

ValueError: [u'path']

 

C:\Users\Pedro\Desktop\Paths test>

Pedro Camargo

unread,
May 19, 2013, 2:08:40 AM5/19/13
to cython...@googlegroups.com
Hi,
          I don't know why, but I decided to run Cython on a dos shell with admin privileges.  That resulted in a successful compilation with the following result:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>cd C:\Users\Pedro\Desktop\Paths test


C:\Users\Pedro\Desktop\Paths test>c:\Python27\python setup_Assignment.py build_e
xt --inplace
running build_ext
cythoning Assignment2.pyx to Assignment2.c
building 'Assignment' extension
creating build
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -Ic:\Python27\lib\site-packages\numpy\core\include -Ic:\Py
thon27\include -Ic:\Python27\PC /TcAssignment2.c /Fobuild\temp.win32-2.7\Release
\Assignment2.obj
Assignment2.c
c:\python27\lib\site-packages\numpy\core\include\numpy\npy_deprecated_api.h(8) :
 Warning Msg: Using deprecated NumPy API, disable it by #defining NPY_NO_DEPRECA
TED_API NPY_1_7_API_VERSION
Assignment2.c(4189) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(4843) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(4947) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(5247) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(5804) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(5837) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(5886) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(6277) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(6888) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(9552) : warning C4018: '<' : signed/unsigned mismatch
Assignment2.c(15223) : warning C4305: '=' : truncation from 'double' to '__pyx_t
_10Assignment_DTYPE_t'
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\link.exe /DLL /nologo
/INCREMENTAL:NO /LIBPATH:c:\Python27\libs /LIBPATH:c:\Python27\PCbuild /EXPORT:i
nitAssignment build\temp.win32-2.7\Release\Assignment2.obj "/OUT:C:\Users\Pedro\
Desktop\Paths test\Assignment.pyd" /IMPLIB:build\temp.win32-2.7\Release\Assignme
nt.lib /MANIFESTFILE:build\temp.win32-2.7\Release\Assignment.pyd.manifest
   Creating library build\temp.win32-2.7\Release\Assignment.lib and object build
\temp.win32-2.7\Release\Assignment.exp


C:\Users\Pedro\Desktop\Paths test>

Any ideas?

Thanks,
              Pedro
Reply all
Reply to author
Forward
0 new messages