python subprocess.popen not honouring LD_LIBRARY_PATH

Viewed 2194

I'm trying to spawn a subprocess from python using the following code in a python script:

p = subprocess.Popen(['./appleseed.cli', '--version'])

the problem is the command relies on a shared library so i get the following error

./appleseed.cli: error while loading shared libraries: libappleseed.so: cannot open shared object file: No such file or directory

I have the main binary in the system PATH and also the lib in LD_LIBRARY_PATH but that doesn't seem to help. These are set in ~/.bash_profile.

Interestingly if I run the same code in an interactive python session it works, also specifying the command as appleseed.cli without the ./ works as well.

I'm, running ubuntu and python 2.7

UPDATE:

Heres the full python file I'm using:

import argparse
import subprocess


def print_appleseed_version(args):

    p = subprocess.Popen(['./appleseed.cli', '--version'])


def main():
    # Parse the command line.
    parser = argparse.ArgumentParser()
    parser.add_argument("-t", "--tool-path", metavar="tool-path")
    args = parser.parse_args()
    
    print_appleseed_version(args)


if __name__ == '__main__':
    main()

and i run this code from the command line like so:

sudo python ../test.py -t appleseed.cli
0 Answers
Related