OSX:Maya的Python实例取代了`python`

时间:2014-06-12 18:47:12

标签: python macos maya

在我的OSX 10.9.2上,我安装了Maya 2014学生版,它随Python 2.7.3一起提供。问题是,现在每当我在bash中运行python时,Maya的Python解释器总是会启动,它位于:

/Applications/Autodesk/maya2014/Maya.app/Contents/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

我已使用pythonwhich验证了ls -l确切指出的内容:

$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

$ ls -l /Library/Frameworks/Python.framework/Versions/2.7/bin/python
lrwxr-xr-x  1 root  admin  7 May 24 12:21 /Library/Frameworks/Python.framework/Versions/2.7/bin/python -> python2

$ ls -l /Library/Frameworks/Python.framework/Versions/2.7/bin/python2
lrwxr-xr-x  1 root  admin  9 May 24 12:21 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2 -> python2.7

$ ls -l /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
-rwxrwxr-x  1 root  admin  25624 Nov 10  2013 /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

这意味着python最终指向python2.7,后者是可执行文件而不是链接。但是,当我运行python并使用Ctrl + Z暂停解释程序并使用ps列出流程时,我看到了:

67937 ttys001    0:00.03 /Applications/Autodesk/maya2014/Maya.app/Contents/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

关于如何发生这种情况的任何想法?非常感谢。

1 个答案:

答案 0 :(得分:0)

事实证明,.profile中的以下行覆盖了预期的python可执行路径:

MAYA_LOCATION=/Applications/Autodesk/maya2014/Maya.app/Contents
export MAYA_LOCATION
DYLD_FRAMEWORK_PATH=$DYLD_FRAMEWORK_PATH:$MAYA_LOCATION/Frameworks
export DYLD_FRAMEWORK_PATH

在对这些内容进行评论后,我设法/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python正在运行。

根据Mac Developer Library(https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html),DYLD_FRAMEWORK_PATH会覆盖将在其中搜索框架的目录。但奇怪的是,即使/usr/local/bin/python指向/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/PythonDYLD_FRAMEWORK_PATH仍然可以覆盖它。

实际已解决,但仍不知道DYLD_FRAMEWORK_PATH如何影响/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python