Updates to enviironment variables and ctypes

Scott Flynn scott at starlon.net
Wed May 13 08:10:25 CEST 2009

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

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090513/bb34cbc9/attachment.html>

More information about the Python-list mailing list