setting environment variables
William Park
parkw at better.net
Mon Jun 19 15:19:53 EDT 2000
More information about the Python-list mailing list
Mon Jun 19 15:19:53 EDT 2000
- Previous message (by thread): bl
- Next message (by thread): setting environment variables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Jun 19, 2000 at 09:04:47PM +0200, Walter Hofmann wrote: > > Hi, > > I need to set an environment variable so that a python module which I'd > like to use finds the right shared library. > > I'm using Linux, so doing > > LD_LIBRARY_PATH=/opt/kde2/qt/lib python test.py > > works. But I would prefer to do it in python so that one can start my > program by entering > > ./test.py > > However, setting LD_LIBRARY_PATH with os.environ within the python > script (but before importing the library) is too late. The dynamic > linker will not find the library this way. > > I then tried to use > > #!/usr/bin/env LD_LIBRARY_PATH=/opt/kde2/qt/lib python test.py > > which, according to env's manpage should work. It doesn't, but hangs > instead in a tight loop consoming 100% CPU. Neither works the more > complex > > #!/bin/bash -c 'LD_LIBRARY_PATH=/opt/kde2/qt/lib python ./test.py' > > which gives > > wh at frodo:~/programming/qtpython > ./test.py > bash: - : unrecognized option > Usage: bash [GNU long option] [option] ... > [...] > > Finally, I found out that the following rather tricky (dual language) > code works, however it is ugly to say the best: > > #!/bin/sh > LD_LIBRARY_PATH="/usr/lib/qt-2.1.1/lib" "exec" "python" "$0" "$*" > del LD_LIBRARY_PATH > # python code starts here > > > My question: > Is anyone on this list aware of a cleaner way to to this? > > > Walter I don't think you can change shared library path inside Python. Since you're running Linux, add '/opt/kde2/qt/lib' to /etc/ld.so.conf'. --William
- Previous message (by thread): bl
- Next message (by thread): setting environment variables
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list