在OSX上将DYLD_LIBRARY_PATH和/或LD_LIBRARY_PATH带入python

时间:2016-06-05 01:10:21

标签: python macos

我有一个使用一些动态库的可执行文件,当'DYLD_LIBRARY_PATH'设置正确时,它可以从OSX终端成功运行:

airbook:layoutSpaceTest daniel$ echo $DYLD_LIBRARY_PATH
/Developer/NVIDIA/CUDA-7.5/lib:/Developer/OptiX/lib64
airbook:layoutSpaceTest daniel$ heliosim -f degraded.sunshapein
'HelioSim'  Port: 1200 with 1 threads
'HelioSim' ENDED

但是我无法在python中运行可执行文件,因为它没有选择'DYLD_LIBRARY_PATH'或'LD_LIBRARY_PATH':

airbook:layoutSpaceTest daniel$ python
Python 2.7.10 (default, Aug 22 2015, 20:33:39)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os,sys
>>> os.environ["DYLD_LIBRARY_PATH"]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'DYLD_LIBRARY_PATH'

我已经读过/ usr / bin / env python从导入的环境剥离DYLD_LIBRARY_PATH和LD_LIBRARY_PATH。有办法防止这种情况吗?

非常感谢任何帮助!

(python 2.7,OSX el capitan)

0 个答案:

没有答案