F
fredbasset1000
Hi All,
I've written a simple Python extension module in C, but Python is
having problems trying to locate it when I import it into an existing
Python file. In my example, I wrote a C extension called "diomodule"
which exists in the directory : /root/project/drivers/dio/
diomodule.c. It has compiled fine and I end up with a diomodule.so
file in that same directory. I have problems when trying to import it
into another Python file however, e.g. in a file /root/project/daemon/
daemon.py I tried to import it with "import
project.drivers.dio.diomodule". Python throws an error however when I
try to call one of the functions:
File "/root/project/daemon/daemon.py", line 115,
in ?
diomodule.init
()
NameError: name 'diomodule' is not defined
I can only get it to work if I copy the .so file to the directory
where daemon.py is and change the import to "import diomodule".
So my question is why can't Python locate the new extension module
when I try to import it with "import project.drivers.dio.diomodule"?
Thanks for any responses,
Fred
I've written a simple Python extension module in C, but Python is
having problems trying to locate it when I import it into an existing
Python file. In my example, I wrote a C extension called "diomodule"
which exists in the directory : /root/project/drivers/dio/
diomodule.c. It has compiled fine and I end up with a diomodule.so
file in that same directory. I have problems when trying to import it
into another Python file however, e.g. in a file /root/project/daemon/
daemon.py I tried to import it with "import
project.drivers.dio.diomodule". Python throws an error however when I
try to call one of the functions:
File "/root/project/daemon/daemon.py", line 115,
in ?
diomodule.init
()
NameError: name 'diomodule' is not defined
I can only get it to work if I copy the .so file to the directory
where daemon.py is and change the import to "import diomodule".
So my question is why can't Python locate the new extension module
when I try to import it with "import project.drivers.dio.diomodule"?
Thanks for any responses,
Fred