问题描述
我对Python的了解仍然非常基础,并且我现在只是想尽一切办法在Maya中使用/调用库. (因为我需要从QT Designer创建基本的UI,并在将其转换为.py文件后在Maya中打开它)
My knowledge of Python is still pretty basic, and I am only now trying to wrap my head around how to use / call libraries from within Maya. (Because I need to create a basic UI from QT Designer and have it be opened in Maya after converting it to a .py file)
在我学会了将.ui正确转换为.py之后,现在我在Maya中遇到此错误
After I learned to properly convert a .ui to a .py, I now get this error in Maya
我尝试遵循所说的这里和此处,但即使如此-在设置了这些环境变量之后...
I tried following what was said here and here, but even then - after setting these environment variables...
PYTHONPATH = C:\ Python34
PYTHONPATH = C:\Python34
...我仍然无法运行基本的.py文件.实际上-只要PYTHONHOME变量有效,Maya中的Python就不再执行任何操作.
... I a still unable to run a basic .py file. In fact - as long as the PYTHONHOME variable is in effect, Python from within Maya no longer does anything.
下面的代码是转换从QT Designer中保存的.ui文件后得到的python文件.
This code below is the resulting python file that I got from converting the .ui file that I saved out of QT Designer.
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'test.ui'
#
# Created by: PyQt5 UI code generator 5.4.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.buttonBox = QtWidgets.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(30, 240, 341, 32))
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.retranslateUi(Dialog)
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
在尝试使用PySide之后,我遇到了一些不同的在线笔记:
I've come across some different online notes that advised the use of PySide, and after trying to use:
from PySide.QtCore import *
from PySide.QtGui import *
我仍然无法测试它是否有效,因为显然QtWidgets不是模块吗?
I still couldn't test if this works, because apparently QtWidgets isn't a module?
我很迷路.更大的图景是,我只希望能够运行从Maya脚本编辑器通过QT Designer创建的ui.我不知道从哪里开始学习图书馆.这里有人愿意提供一些建议吗?
I'm pretty lost. The bigger picture is that I just want to be able to run a ui created from QT Designer from Maya's script editor. I have no idea where to begin with learning about libraries. Would anyone here be kind enough to give some advice?
其他信息:
I am using Maya 2016, running on a Windows 10 64 bit OS.
I also have a Python 2.7 in my C: drive
And I am using PyQt5-5.4.1-gpl-Py3.4-Qt5.4.1-x64
谢谢您的时间.
推荐答案
Maya的python解释器版本为2.7(对于Maya 2013及更早版本,为2.6).您的PYTHONPATH
指向python 3.4安装.您还想确保如果您的Python 3.4在PATH
中,则它晚于maya python的安装位置.所有这些都是为了确保Maya不会感到困惑,并尝试运行它无法处理的python 3代码或dll.
Maya's python interpreter is in the 2.7 series (or 2.6 for Maya 2013 and earlier). Your PYTHONPATH
is pointing at a python 3.4 install. You also want to make sure that if your Python 3.4 is in PATH
it comes later than the maya python install location. This is all to makes sure that Maya doesn't get confused and try to run python 3 code or dlls which it cannot handle.
此外,Maya 2016正在PyQT4上运行. Maya 2017在PyQT5上运行.因此,您可能要使用PyQT4版本的设计器
Also, maya 2016 is running on PyQT4. Maya 2017 runs on PyQT5. So you'll probably want to use a PyQT4 version of designer
相关:
- UIC / PyQT4 example
- using UIC files in Maya pyQT 4
- re: 2017/QT5
这篇关于"python34.dll的模块使用与此版本的Python冲突".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!