The problem relates to running the 'GAMMA SAR and Interferometry Software' (GAMMA). To process data in GAMMA, the user needs to type complex commands in the shell. Instead of this tedious process, I'm trying to use Python to prepare these commands as strings and would like to run/execute those directly from Python.
Below is a simplified example of a working solution: I prepare a string in Python and print it to the command line. If I then manually copy/paste the string that Python prints to the shell to the same shell, Gamma runs smoothly.
The working code:
# Visualize interferogram
p = 'dismph TMX.int 1189'
print(p) #copy/pasting this output to a command line runs the external program
This gets tedious as each command needs to be copy/pasted from a shell to another shell. Instead, I want to just run Python and print the commands to the shell where they get executed. The following code is capable of printing a string to the shell and executing it.
The problem code:
import os
# Visualize interferogram
p = 'dismph TMX.int 1189'
os.system(p)
Unfortunately, I get the following error message.
The error:
dyld: Library not loaded: libDIFF.dylib
Referenced from: /Users/[username]/[programname]/[functionname]/bin/dismph
Reason: image not found
This sample is run on OSX El Capitan, Version 10.11.4, with Python 3.5.1 |Anaconda 2.4.1 (x86_64)| (default, Dec 7 2015, 11:24:55) [GCC 4.2.1 (Apple Inc. build 5577)] on darwin:
Another way of asking this question: What is the difference between typing and running a command in a shell vs. printing and executing the same string from Python. Technically, both should see the same variables/paths/libraries, but in this case there seems to be a difference. GAMMA doesn't seem to be able to find the necessary libraries.