-2

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.

  • 2
    any code, only theory? – Haifeng Zhang Apr 07 '16 at 22:20
  • [Look at this related question](http://stackoverflow.com/questions/17703510/dyld-library-not-loaded-reason-image-not-loaded). Seems like you are missing a dependency or that the required dependency cannot be found. Need to some code to diagnose it further. What OS are you on? Could very likely be a simple path problem for shared libs. – MS-DDOS Apr 07 '16 at 22:24
  • This may be platform dependent. Are you using Apple iOS? Which version? Is this a 32 or 64 bit python? – tdelaney Apr 07 '16 at 22:25
  • You shall narrow your problem to simple case, show us the code, provide info about OS, show error trace. Your current description is too wide. – Jan Vlcinsky Apr 07 '16 at 22:25
  • Can you post the exact command line that does this? You sure that running it from the command line works? Do you have multiple `dismph` installed so that perhaps running it with absolute path verses relative path find different executables? – tdelaney Apr 07 '16 at 22:28
  • Possible duplicate of [dyld: Library not loaded: @rpath/libswift\_stdlib\_core.dylib](http://stackoverflow.com/questions/24002836/dyld-library-not-loaded-rpath-libswift-stdlib-core-dylib) – DevLounge Apr 07 '16 at 22:41
  • Point taken, added more info and code. And yes, running from command line works. I don't have multiple dismph installed. – DrCheshireNeko Apr 07 '16 at 22:50
  • I have clarified the post after initial comments. Please re-open the post after consideration. – DrCheshireNeko Apr 13 '16 at 00:05

1 Answers1

0

I'm going to answer my own question in the hope that others will see this solution and it'll help them troubleshoot similar problems.

The issue I was seeing has to do with the new security upgrade of El Capitan called SIP (System Integrity Protection). It prevents modification of certain environment variables and modification of programs in protected system directories. El Capitan will not allow subprocesses to reassign certain environment variables to prevent malicious programs from subverting the system security. https://support.apple.com/en-us/HT204899 and http://www.macworld.com/article/2948140/os-x/private-i-el-capitans-system-integrity-protection-will-shift-utilities-functions.html

The simple solution is to copy the shared object libraries to /usr/local/lib (or your respective default PATH variable), and then all works as before.

It is possible to turn off SIP on El Capitan, but it has to be done by booting into the recovery partition and turning off SIP for your installation.