Skip to main content
 首页 » 编程设计

python之操作系统 : Maya Python Qt conflict with system libraries

2025年05月04日15jyk

我正在尝试解决导致 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 的应用程序链接到 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/

几个原因:

  • 您正在配置文件中设置 PYTHONPATH(.bashrc、.profile、.zshrc ...)并从命令行运行 Maya。在这种情况下,您有两种选择。从您的配置文件中删除 PYTHONPATH,或者在运行 Maya 之前添加一个替您执行此操作的别名,

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

  • 您在某处有一个.pth 文件链接到/usr/local/lib/python2.7/site-packages/。只需检查 sys.path 返回的文件夹列表。

希望对你有帮助