ImportError: No module named Cython.Shadow

541 views
Skip to first unread message

Czarek Tomczak

unread,
Jul 19, 2013, 3:45:58 AM7/19/13
to cython...@googlegroups.com
Hi,

On some systems (XP this time) I get this error when importing PYD module created using Cython:

Traceback (most recent call last):
  File "cefadvanced.py", line 21, in <module>
    import cefpython_py27 as cefpython
  File "imports.pyx", line 29, in init cefpython_py27 (cefpython.cpp:71240)
ImportError: No module named Cython.Shadow

In imports.pyx on line 29 I am importing the "void":

from Cython.Shadow import void 

Am I supposed to install Cython to be able to use the PYD file? That doesn't make much sense, because
on other computers it works fine with no Cython installed. I had this error reported twice for my application,
this time I know more details about the system it is running on, it's XP SP3 and Python 2.7.2.

Best regards,
Czarek

Czarek Tomczak

unread,
Jul 19, 2013, 3:52:35 AM7/19/13
to cython...@googlegroups.com
Code in question in the cefpython.cpp Cython generated file:

  /* "C:\cefpython\cefpython-src\cefpython\cef1\windows\setup\imports.pyx":29
 *     from urllib.request import pathname2url as urllib_pathname2url
 * 
 * from Cython.Shadow import void             # <<<<<<<<<<<<<<
 * from cpython.version cimport PY_MAJOR_VERSION
 * import weakref
 */
  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[36]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(((PyObject *)__pyx_n_s__void));
  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s__void));
  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__void));
  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s_221), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[36]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s__void); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[36]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_d, __pyx_n_s__void, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[36]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

-Czarek 

Czarek Tomczak

unread,
Jul 19, 2013, 5:40:00 AM7/19/13
to cython...@googlegroups.com
It seems that the void type is now built-in in Cython, I'm not sure in which release did this happen.
I have removed the "Cython.Shadow" imports and it compiles fine on Linux, I hope this will
also compile fine on Windows and hopefully fix the other strange problem when trying to
import the PYD module on XP SP3 in an application that was converted using py2exe, the 
error message was obscured:

Traceback (most recent call last):
  File "CyMS.py", line 38, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "cefpython1\__init__.pyc", line 4, in <module>
  File "zipextimporter.pyc", line 82, in load_module
  File "cefpython1\cefpython_py27.pyc", line 9, in <module>
  File "cefpython1\cefpython_py27.pyc", line 7, in __load
ImportError: DLL load failed: The specified procedure could not be found.

Could the Cython.Shadow import problem be the cause of it?

Regards,
Czarek

Stefan Behnel

unread,
Jul 19, 2013, 6:33:12 AM7/19/13
to cython...@googlegroups.com
Czarek Tomczak, 19.07.2013 11:40:
> It seems that the void type is now built-in in Cython, I'm not sure in
> which release did this happen.

It's been there forever.


> I have removed the "Cython.Shadow" imports

Actually, you should never use that module directly. The right way to use
it is by saying "import cython" (or "cimport cython"), and if you want your
code to run without having Cython installed, then ship the Cython.Shadow
module with your code as "cython.py". You definitely don't need it just to
make use of the normal C types (except when you are writing Pure Python
Mode code, that is...).


> and it compiles fine on Linux, I
> hope this will
> also compile fine on Windows and hopefully fix the other strange problem
> when trying to
> import the PYD module on XP SP3 in an application that was converted using
> py2exe, the
> error message was obscured:
>
> Traceback (most recent call last):
>> File "CyMS.py", line 38, in <module>
>> File "zipextimporter.pyc", line 82, in load_module
>> File "cefpython1\__init__.pyc", line 4, in <module>
>> File "zipextimporter.pyc", line 82, in load_module
>> File "cefpython1\cefpython_py27.pyc", line 9, in <module>
>> File "cefpython1\cefpython_py27.pyc", line 7, in __load
>> ImportError: DLL load failed: The specified procedure could not be found.
>
> Could the Cython.Shadow import problem be the cause of it?

No idea. Looks like it can't find the module init function. That would be
rather surprising, but then again, I don't know what py2exe does in order
to bundle and load DLLs.

Stefan

Czarek Tomczak

unread,
Jul 19, 2013, 10:49:35 AM7/19/13
to cython...@googlegroups.com, stef...@behnel.de
Hi Stefan,

Thank you for the feedback. Getting rid of the "Cython.Shadow" imports solved the import problem
on Windows. The other problem with the "procedure could not be found" was because someone 
copied some system DLLs from Windows 7 to the application directory. These DLLs link to an
incompatible Visual C runtime library causing an error on XP.

Best regards,
Czarek
Reply all
Reply to author
Forward
0 new messages