5

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
Community
  • 1
  • 1
jonathan topf
  • 7,897
  • 17
  • 55
  • 85
  • How are you launching the python script? Are the variables set in the execution environment? Having them in your `bash_profile` will not help if you're not using bash to launch the script, or if you're running as other user. Also, you can [specify the environment variables manually on Popen](http://stackoverflow.com/questions/2231227/python-subprocess-popen-with-a-modified-environment) – loopbackbee Dec 16 '13 at 13:13
  • .bash_profile is ignored if you don't pass `shell=True` to `Popen` – Alleo Dec 19 '15 at 13:41

0 Answers0