0

Sorry if I didn't find another post related to my issue.

I have a binary "class" that I launch with current environment of my SHELL and the execution is fine : $ ./class params.ini

But things come complicated when I try to execute it from os.system :

Indeed, I get :

>>> os.system('./class params.ini')
dyld[38384]: Library not loaded: @rpath/libmkl_intel_lp64.2.dylib
  Referenced from: <53D32B9F-B970-3385-9B2F-304FA4654A63> /Users/fab/Phd_2019_2020/Travail_3_Alain_Injection_des_Biais_Spectro_dans_XSAF_avec_GCph_plus_WL_plus_XC_et_rajout_dun_Prior_dans_la_matrice_de_Fisher_de_SpecSAF_15_JANVIER_2020/MAIN_DIRECTORY_11_BINS_AND_INJECTION_BINS_FROM_GCph_INTO_GCsp/TotallySAF_Alpha_COMPUTE_ERROR_ON_SQUARED_RATIO_BIAS_SPECTRO_BIAS_PHOTO/XSAF_C/CLASS/class
  Reason: tried: '/opt/intel/oneapi/compiler/2022.2.0/mac/bin/intel64/../../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/intel/oneapi/compiler/2022.2.0/mac/bin/intel64/../../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/lib/libmkl_intel_lp64.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/lib/libmkl_intel_lp64.2.dylib' (no such file), '/../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/opt/intel/oneapi/compiler/2022.2.0/mac/bin/intel64/../../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/intel/oneapi/compiler/2022.2.0/mac/bin/intel64/../../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/lib/libmkl_intel_lp64.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/lib/libmkl_intel_lp64.2.dylib' (no such file), '/../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/../compiler/lib/libmkl_intel_lp64.2.dylib' (no such file), '/usr/local/lib/libmkl_intel_lp64.2.dylib' (no such file), '/usr/lib/libmkl_intel_lp64.2.dylib' (no such file, not in dyld cache)
6

I know I could add libmkl_intel_lp64.2.dylib to rpath on the binary by doing a :

$ install_name_tool -add_rpath [new_path_rpath] [binary]

But isn't there another simpler solution ? for example, integrate it into ~/.startup.py init file ?

From a general point of view, why my current environment of variables is not kept when I launch an executable from a python script with os.system(./executable)

It seems that before an update from my part, the environment variables were transfered to os.system in my python script before, but this is no more the case.

Maybe the issue is that I build the executable and installation with sudo ( sudo -H make or sudo -E make could help me ?)

Any suggestion is welcome.

guizmo133
  • 11
  • 3
  • use subprocess instead of os - https://docs.python.org/3/library/subprocess.html ? – rasjani Aug 30 '23 at 13:21
  • Even the docs for os.system() say: > The subprocess module provides more powerful facilities for spawning new processes and retrieving their results; using that module is preferable to using this function. – rasjani Aug 30 '23 at 13:32

0 Answers0