【发布时间】:2016-01-13 07:50:09
【问题描述】:
我正在尝试从 Mac 上的 Python 脚本中运行 Fortran 二进制文件。在命令行中,Fortran 二进制文件可以正常工作,但是当我在 Python 中使用 os.system 或 subprocess.open 运行它时,会出现以下错误:
dyld: Library not loaded: libimf.dylib
Referenced from: /Path/To/Binary
Reason: image not found
Fortran 二进制文件是使用 Intel Fortran 构建的。知道这里出了什么问题吗?
编辑:
我在 ~/.bash_profile 中设置了这些环境变量,但没有帮助:
export LD_LIBRARY_PATH="/opt/intel/compilers_and_libraries_2016.0.083/mac/compiler/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries_2016.1.111/mac/compiler/lib"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries/mac/lib"
export DYLD_LIBRARY_PATH="/opt/intel/compilers_and_libraries_2016.0.083/mac/compiler/lib"
export DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries_2016.1.111/mac/compiler/lib"
export DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/intel/compilers_and_libraries/mac/lib"
我正在我的 Mac 上从终端运行 python 脚本。我尝试从 Python 打印
print os.environ['LD_LIBRARY_PATH']
print os.environ['DYLD_LIBRARY_PATH']
两者都给出以下错误:
KeyError: 'DYLD_LIBRARY_PATH'
编辑:
我尝试在我的 Python 代码中使用 os.system 运行另一个二进制文件,效果很好。
【问题讨论】:
-
可能是LD_LIBRARY_PATH问题,检查一下你的命令行和子进程中是否设置了这个。
-
你是直接从你的 bash shell 运行 python 吗?您应该使用详细信息而不是在 cmets btw 中编辑问题
-
您应该使用 os.environ 从 python 脚本中检查您的环境
-
以任何方式运行 fotran 二进制文件(可执行文件)与运行另一种二进制文件有什么不同吗?
标签: python bash fortran intel-fortran