[Cython] ImportError with cimport within package

Mikael Arvids mikael.arvids at enea.com
Thu Feb 26 16:52:26 CET 2009


Hi all,

I'm trying to create package compiled with Cython. It compiles fine but when I try to import it I get an ImportError exception. Here is a simplifed version which generates the same error:

The structure of the compiled package:
  package/
    __init__.py    - Empty
    module_A.pyd
    module_B.pyd
  
Content of the Cython modules:
  module_B.pyx

    cdef class BaseClass:
      ...
      
  module_B.pxd

    cdef class BaseClass:
      pass
    
  module_A.pyx

    cimport module_B

    cdef class SubClass(module_B.BaseClass):
      ...

Content of my test script:
  from package.module_A import Subclass

When I run the test script I get "ImportError: No module named module_B". I works if I put module_B.pyd in the same folder as the test script. I don't understand why since module_A which contains the subclass of the class in module_B is in the same folder as module_B, and there exist no Python imports from the module (which I thought would work as well).

Any suggestions?

(I use Cython 0.10.3, Python 2.5.1 and MSVS C++ 7.1)

Best regards,
Mikael Arvids
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/cython-dev/attachments/20090226/6ce38c75/attachment.htm 


More information about the Cython-dev mailing list