[C++-sig] Problems loading installed extensions: help needed

Jose Vicente Nunez Z josevnz at newbreak.com
Thu Sep 11 01:48:14 CEST 2003


Greetings,

I wrote a Pythin extension module but for some reason i cannot load it
at runtime:


[josevnz at linux0037 TestNative]$ ./scripts/Test.py
Traceback (most recent call last):
  File "./scripts/Test.py", line 6, in ?
    import test.NativeDummy
ImportError: No module named NativeDummy
[josevnz at linux0037 TestNative]$ ./scripts/Test.py
Traceback (most recent call last):
  File "./scripts/Test.py", line 6, in ?
    import test.NativeDummy
ImportError: No module named NativeDummy

But it seems to be installed on the proper location:


[root at linux0037 dist]# rpm -ihv --force python-TestNative-0.0-1.i386.rpm
Preparing...                ###########################################
[100%]
   1:python-TestNative      ###########################################
[100%]
[root at linux0037 dist]# rpm -ql python-TestNative
/usr/lib/python2.2/site-packages/test/Dummy.py
/usr/lib/python2.2/site-packages/test/Dummy.pyc
/usr/lib/python2.2/site-packages/test/NativeDummy.so
/usr/lib/python2.2/site-packages/test/__init__.py
/usr/lib/python2.2/site-packages/test/__init__.pyc

So far this is the code (the extension is called NativeDummy):

#!/usr/bin/env python2
#
# Hello world to test native interfaces in Python
#
import test.NativeDummy
import test.Dummy

argument1 = "Test string argument"
argument2 = 600000
test.NativeDummy(argument1, argument2)
dumber = test.Dummy.Dummy("really dumb")

This is my setup.py file (so far i think all here is ok):

#!/usr/bin/env python2
#
# Hello world to test native interfaces in Python
#
from distutils.core import setup, Extension

VERSION=0
RELEASE=0

extension1 = Extension('test.NativeDummy',
                    define_macros = [('MAJOR_VERSION', VERSION),
                                     ('MINOR_VERSION', RELEASE)],
                    include_dirs = ['/include'],
                    libraries = ['m'],
                    library_dirs = ['/lib'],
                    sources = ['src/c/dummy.c'])

setup (name = 'python-TestNative',
       version = VERSION,
       description = 'My practice native test with Python.',
       author = 'ZZZZ',
       author_email = 'XXX',
       url = 'SSSS',
       package_dir = {'' : 'src/python'},
       packages = ['test'],
       long_description = '''
My practice native test with Python.
Hope this works.
''',
       ext_modules = [extension1])

This is my current directory layout:

[josevnz at linux0037 TestNative]$ find ./
./
./Makefile
./src
./src/python
./src/python/test
./src/python/test/Dummy.py
./src/python/test/__init__.py
./src/python/__init__.py
./src/c
./src/c/dummy.c~
./src/c/dummy.c
./setup.py
./.setup.py.swp
./scripts
./scripts/Test.py
./scripts/Test.py~
./scripts/.Test.py.swp
./dist
./dist/python-TestNative-0.0.tar.gz
./dist/python-TestNative-0.0-1.src.rpm
./dist/python-TestNative-0.0-1.i386.rpm
./README.txt
./build
./build/bdist.linux-i686
./build/bdist.linux-i686/rpm
./build/bdist.linux-i686/rpm/SOURCES
./build/bdist.linux-i686/rpm/SOURCES/python-TestNative-0.0.tar.gz
./build/bdist.linux-i686/rpm/SPECS
./build/bdist.linux-i686/rpm/SPECS/python-TestNative.spec
./build/bdist.linux-i686/rpm/BUILD
./build/bdist.linux-i686/rpm/RPMS
./build/bdist.linux-i686/rpm/RPMS/i386
./build/bdist.linux-i686/rpm/SRPMS
./MANIFEST


I'm using Python 2.2, on Redhat 7.2


Any ideas what i'm doing wrong?







More information about the Cplusplus-sig mailing list