[Pyrex] cimport problems with Python 2.6

Francesc Alted falted at pytables.org
Mon Sep 1 14:33:11 CEST 2008


Hi,

I'm having problems with code that already worked with Pyrex and Python 
2.4/2.5 but that is giving problems with Python 2.6.

I normally use the cimport statement a lot for importing names declared 
in other Pyrex extensions.  As for one:

######## hdf5Extension.pyx #############
from utilsExtension cimport malloc_dims, get_native_type
########################################

being the utilsExtension.pxd contents as follows:

####### utilsExtension.pxd #############
from definitions cimport hsize_t, hid_t

cdef hsize_t *malloc_dims(object)
cdef hid_t get_native_type(hid_t)
########################################

Compilation using Python 2.6 goes well, but I'm experiencing problems 
when running it:

$ PYTHONPATH=. python2.6 tables/tests/test_basics.py
Traceback (most recent call last):
  File "tables/tests/test_basics.py", line 9, in <module>
    import tables
  File "/home/faltet/PyTables/pytables/trunk/tables/__init__.py", line 
76, in <module>
    from tables.file import File, openFile, copyFile
  File "/home/faltet/PyTables/pytables/trunk/tables/file.py", line 44, 
in <module>
    from tables import hdf5Extension
  File "hdf5Extension.pyx", line 11, in hdf5Extension
ImportError: No module named utilsExtension

[Shockingly, line 11 in "hdf5Extension.pyx" corresponds to a docstring]

I've thought that perhaps Python 2.6 is pickier regarding the relative 
imports, so I've tried to replace the line:

from utilsExtension cimport malloc_dims, get_native_type

by this one:

from tables.utilsExtension cimport malloc_dims, get_native_type

(where "tables" is the name of the package)

but the error is now:

/home/faltet/PyTables/pytables/trunk/src/hdf5Extension.pyx:49:0: Cannot 
find .pxd file for module 'tables.utilsExtension'
/home/faltet/PyTables/pytables/trunk/src/hdf5Extension.pyx:49:35: 
Name 'malloc_dims' not declared in module 'tables.utilsExtension'
[other subsequent error lines clipped]

I'm using Pyrex 0.9.8.5 and Python 2.6b3 in a Linux box.

If you want, you can access the SVN branch of the affected code from:

http://pytables.org/svn/pytables/trunk

Thanks in advance,

-- 
Francesc Alted



More information about the Pyrex mailing list