Reputation: 20155
I want to create a package with the following structure:
file.py
package_name/
package_name/__init__.py
package_name/module_a.py
package_name/module_b.so
module_a
uses module_b
and works well. But if I try to load the package package_name
or the containing module module_a
from file.py
, an error occurs, that no module_b
can be found.
What am I doing wrong?
Upvotes: 1
Views: 401
Reputation: 14369
Your LD_LIBRARY_PATH
contains .
which is the current working directory. If you call module_a
directly, it's the directory it is in, if you call file.py
it's file.py
's directory and the library can not be found there. You have several options to changes that.
LD_LIBRARY_PATH
in the environment. That can be done in your .bashrc, in a shell scrip calling your python files, by prefixing the call with LD_LIBRARY_PATH=/your/path
or by modifying os.environ
in Python.Upvotes: 2