简体   繁体   中英

OSX: Maya's Python instance replaces `python`

On my OSX 10.9.2 I have Maya 2014 Student Version installed, which ships with Python 2.7.3. The problem is that now whenever I run python in bash, Maya's Python interpreter is always launched, which is located at:

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

I have verified what python exactly points to by using which and 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

Which means that python eventually points to python2.7 , the latter being an executable instead of a link. But when I run python and suspend the interpreter using Ctrl + Z and list the processes using ps , I see:

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

Any ideas on how this could happen? Thanks a lot.

It turns out that it is the following lines in .profile that overrides the expected python executable path:

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

After commenting these lines out, I managed to have /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python running.

According to Mac Developer Library ( https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html ), DYLD_FRAMEWORK_PATH overrides the directories in which frameworks will be searched for. But it is weird that even if /usr/local/bin/python points to /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python , DYLD_FRAMEWORK_PATH is still able to override it.

Practically solved, but still don't know how DYLD_FRAMEWORK_PATH affects /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM