Scott Flynn wrote:
I was hoping I could update LD_LIBRARY_PATH at runtime and load a library
through ctypes from there, but I haven't been able to.
I've tried all of these.
os.environ['LD_LIBRARY_PATH'] = "./lib"
os.putenv('LD_LIBRARY_PATH', "./lib")
os.system("export LD_LIBRARY_PATH=./lib")
lib = CDLL("libevaluator.so")
Traceback (most recent call last):
File "Evaluator.py", line 9, in <module>
lib = CDLL("libevaluator.so")
File "/usr/lib/python2.5/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libevaluator.so: cannot open shared object file: No such file or
directory
The only thing that works is to set the variable before starting Python. I'm
assuming that's just how it's going to be. Is this a bug or is it meant to
be?
(You should mention that you're using Unix, and probably what version of
Python you're using. It might make a difference.)
Doesn't ctypes.LoadLibrary() accept a pathname as argument? That's what
the Python 2.6 docs say. I haven't experimented, but it'd be worth a
try. In this case, I'd make it an absolute path, just to convince it
not to look through the directories in the LD_LIBRARY_PATH.
--
http://mail.python.org/mailman/listinfo/python-list