Interactive os.environ vs. os.environ in script

boris.smirnov at gmail.com boris.smirnov at gmail.com
Mon Feb 26 10:08:48 EST 2007


Hi there,

I have a problem with setting environment variable in my script that
uses qt library. For this library I have to define a path to tell the
script whre to find it.

I have a script called "shrink_bs_070226" that looks like this:
**********************************
import sys, re, glob, shutil
import os

os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'

from qt import *
***********************

When I run this script I get this error:


> python shrink_bs_070226.py
Traceback (most recent call last):
  File "shrink_bs_070226.py", line 25, in ?
    from qt import *
  File "/path/Linux/python/rh_linux/lib/python2.2/site-packages/
qt.py", line 46, in ?
    import libsip
ImportError: libadamsqt.so: cannot open shared object file: No such
file or directory

What is important here that when I set this variable interactive in
python session, there is no problem with import.

> python
Python 2.2.3 (#1, Aug  8 2003, 08:44:02)
[GCC 3.2.3 20030502 (Red Hat Linux 3.2.3-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os

>>> import shrink_bs_070226
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "shrink_bs_070226.py", line 25, in ?
    from qt import *
ImportError: No module named qt

>>> os.environ["LD_LIBRARY_PATH"]='/path/Linux/rh_linux'

>>> import shrink_bs_070226
>>>

Could anybody explain me the logic here? Am I missing something?
Thank in advance.
Rg
Boris




More information about the Python-list mailing list