OSX: Maya Python Qt 与系统库冲突

OSX: Maya Python Qt conflict with system libraries

我正在尝试解决导致 Maya 崩溃的 Qt 库冲突问题。当我从终端 运行 Maya 时,我得到:

objc[4152]: Class QCocoaColorPanelDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QMacSoundDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaPanel is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaView is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaWindow is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaWindowDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaMenuLoader is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QNSApplication is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaApplicationDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaWindowCustomThemeFrame is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaToolBarDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaMenu is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QNSOpenSavePanelDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaFontPanelDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QNSPanelProxy is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QNSWindowProxy is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaPageLayoutDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QCocoaPrintPanelDelegate is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QNSImageView is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QNSStatusItem is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.
objc[4152]: Class QNSMenu is implemented in both /Applications/Autodesk/maya2016/Maya.app/Contents/MacOS/QtGui and /usr/local/lib/QtGui.framework/Versions/4/QtGui. One of the two will be used. Which one is undefined.

我的解决方法是隐式设置指向 Qt 库的 PYTHONPATH 环境变量:

/Applications/Autodesk/maya2016/Maya.app/Contents/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

但这会导致其他使用 Qt 的应用程序 link 到 Maya 的自定义 Qt 构建,从而产生另一个冲突(不同的构建和 Python 版本)。

我猜这是一个 OSX 特定的问题。如何强制应用程序 运行 自己的 Qt 库?

编辑: 我删除了与 brew 一起安装的 Qt、PySide 和 Shiboken 包,以检查它们是否被 Maya 拾取。在没有设置 PYTHONPATH 的情况下,PySide 仍然从系统目录中获取:

import PySide
PySide.__file__
# Result: /usr/local/lib/python2.7/site-packages/PySide/__init__.pyc # 

我今天遇到了同样的问题,已经解决了。所以这可能会有所帮助。

首先从 Maya 内部检查您的 sys.path:

for p in sys.path:
    print p

您现在应该看到它列出的是错误的 /usr/local/lib/python2.7/site-packages/

几个原因:

  • 您正在从命令行设置配置文件(.bashrc、.profile、.zshrc ...)中的 PYTHONPATH 和 运行 Maya。在这种情况下,您有两种选择。从您的配置文件中删除 PYTHONPATH,或者在 运行 Maya、

    之前添加一个替您完成此操作的别名

    沿着这些线的东西: alias maya=export PYTHONPATH="";/App/Maya/macos/maya

  • 您在 link 到 /usr/local/lib/python2.7/site-packages/ 的某处有一个 .pth 文件。只需检查 sys.path.

  • 返回的文件夹列表

希望对您有所帮助