bash - Python script calling shell script with Image Magick -


i have bash script has calls "convert" command in imagemagick. script works fine when execute in terminal manually. have path 'convert' command added system path. when try execute using script(written in python) , run error 'convert' not found. here simple example reproduce issue. on osx maverick.


shell script: convert_svg_to_png.sh

#!/bin/bash filename in *.svg;          convert "$filename" "`basename $filename .svg`.png"  done 

python script: runme.py

import subprocess  subprocess.call('./convert_svg_to_png.sh') 

error: ./convert_svg_to_png.sh: line 5: convert: command not found


any idea why error?

edit: when bash script modified include whole path convert function. new error pops up:

dyld: library not loaded: /imagemagick-6.8.9/lib/libmagickcore-6.q16.2.dylib referenced from: %fullpath%convert reason: image not found

the shell being called python /bin/bash. same in terminal.

a few things...

  1. ensure convert utility reachable $path environment variable.

    export path="${path}:/users/myusername/desktop/libraries/imagemagick-6.8.9/bin" 
  2. if imagemagick's ecosystem lives in special place, set environment $magick_home; such that, runtime libraries can find everything.

    export magick_home=/users/myusername/desktop/libraries/imagemagick-6.8.9 
  3. when invoking subprocess.call, set keyword argument shell=true.

    import subprocess  subprocess.call('./convert_svg_to_png.sh', shell=true) 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -