Maya 2017-- Qt5 and pyside questions.

474 views
Skip to first unread message

jettam

unread,
Oct 17, 2017, 8:10:33 PM10/17/17
to Python Programming for Autodesk Maya

I am learning how to load a UI with pyside_dynamic. The problem is the tutorials where written for earlier version of Maya. (I am using maya2017)

Here is the code I have been instructed to write. The error is this:    "No module named PySide.QtCore"  What should I write instead ?
I read a blog that said "Maya 2017 was released today and with it comes a big change; PySide (and PyQt4) no longer works with Maya."

# Error: No module named PySide.QtCore
# Traceback (most recent call last):
#   File "<maya console>", line 1, in <module>
#   File "E:\ProfessionalDevelopment\python\Introduction to Python Scripting in Maya\cgcircuitPython\wk6\geomGenerator_pysideDynamic.py", line 6, in <module>
#     import pyside_dynamic2
#   File "C:/Users/justin/Documents/maya/2017/scripts\pyside_dynamic2.py", line 42, in <module>
#     from PySide.QtCore import Slot, QMetaObject
# ImportError: No module named PySide.QtCore #


import os
from PySide2 import QtWidgets, QtCore, QtUiTools, QtGui
from shiboken2 import wrapInstance

import pyside_dynamic2

import maya.cmds as mc
import maya.OpenMayaUI as omui

def getMayaWindow():
   
''' pointer to the maya main window '''
    ptr
= omui.MQtUtil.mainWindow()
   
if ptr:
       
return wrapInstance(long(ptr), QtWidgets.QMainWindow)

def run():
   
''' builds our UI '''
   
global win
    win
= GeometryGenerator(parent=getMayaWindow())
    win
.show()

uiFilePath
= os.path.join( os.path.dirname(__file__) , 'geomGenerator_v001.ui')
   
class GeometryGenerator(QtWidgets.QDialog):
   
   
def __init__(self,parent=None):
       
super(GeometryGenerator,self).__init__(parent)
       
self.ui = pyside_dynamic2.loadUi(uiFilePath,self)

Justin Israel

unread,
Oct 17, 2017, 8:53:07 PM10/17/17
to python_in...@googlegroups.com
Do you see the difference between how you are importing PySide (1.x) in your pyside_dynamic2 module, and PySide2 (2.x) in your geomGenerator_pysideDynamic.py module?
 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/85eaa7d7-23a5-46df-9fd6-c4007e34eeec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Simon Anderson

unread,
Oct 17, 2017, 8:54:36 PM10/17/17
to Python Programming for Autodesk Maya
Looks like in you are importing the wrong module, for the version of Maya you are using.

you need to import PySide2, like you do in your code snippet. In one of your modules you are importing PySide.

a good rule of thumb is to implement a try, where you try import pyside2, and then if that fails import pyside1

try:

from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2 import __version__
from shiboken2 import wrapInstance
except ImportError:

from PySide.QtCore import *
from PySide.QtGui import *
from PySide import __version__
from shiboken import wrapInstance

jettam

unread,
Oct 17, 2017, 9:20:21 PM10/17/17
to Python Programming for Autodesk Maya
I am getting confused. So I need to back up a bit. It all relates to being able to launch a pyside_dynamic ui in maya.

I have been asked to drop this pyside_dynamic2.py file (see attached) into my maya scripts dir. When I try to import it I get this error. 

import pyside_dynamic2
# Error: No module named PySide.QtCore
# Traceback (most recent call last):
#   File "<maya console>", line 1, in <module>
#   File "C:/Users/justin/Documents/maya/2017/scripts\pyside_dynamic2.py", line 42, in <module>
#     from PySide.QtCore import Slot, QMetaObject
# ImportError: No module named PySide.QtCore # 

Do I need to edit this script or is it redundant now with maya2017 ? 
pyside_dynamic2.py

Simon Anderson

unread,
Oct 17, 2017, 9:49:18 PM10/17/17
to Python Programming for Autodesk Maya
I took a look at the file. 

It was build using pyside 1, and Maya 2017 uses pyside 2. So in order to get this to work in maya, you will have to update the file, and migrate all the pyside 1 modules and calls to pyside 2. 

It can be a good task, as you learn about the changes in the API.

Here is a link to Maya pyside.

jettam

unread,
Oct 17, 2017, 10:43:04 PM10/17/17
to Python Programming for Autodesk Maya
Thanks Simon,
 I switched out all PySide to read PySide2. I also switch QtGui to QtWidgets

damon shelton

unread,
Oct 17, 2017, 10:47:31 PM10/17/17
to python_in...@googlegroups.com
As a note. Not all qtgui was moved to qtwidgets. Some things still live in qtgui. Not just a search and replace 

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

jettam

unread,
Oct 18, 2017, 3:09:41 PM10/18/17
to Python Programming for Autodesk Maya
This page shows me all the modules for  pySide https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/index.html  

I have found this page for pySide2 https://wiki.qt.io/PySide2 But I am unable to see a list of pySide2's available modules? 


Justin Israel

unread,
Oct 18, 2017, 4:14:27 PM10/18/17
to python_in...@googlegroups.com
On Thu, Oct 19, 2017 at 8:09 AM jettam <justin...@gmail.com> wrote:
This page shows me all the modules for  pySide https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/index.html  

I have found this page for pySide2 https://wiki.qt.io/PySide2 But I am unable to see a list of pySide2's available modules? 

The first one is generated and hosted by some domain. I didn't find anyone hosting the built pyside2 docs . I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch.



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Deke Kincaid

unread,
Oct 19, 2017, 10:16:05 AM10/19/17
to python_in...@googlegroups.com
Pyside is now maintained by the qt company, so the builds are now all on their qt-project.org code site.

Marcus Ottosson

unread,
Oct 19, 2017, 11:37:07 AM10/19/17
to python_in...@googlegroups.com
Are you saying the docs for PySide2 is on qt-project.org? Where, exactly? :S

On 19 October 2017 at 15:15, Deke Kincaid <dekek...@gmail.com> wrote:
Pyside is now maintained by the qt company, so the builds are now all on their qt-project.org code site.
On Wed, Oct 18, 2017 at 13:14 Justin Israel <justin...@gmail.com> wrote:
On Thu, Oct 19, 2017 at 8:09 AM jettam <justin...@gmail.com> wrote:
This page shows me all the modules for  pySide https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/index.html  

I have found this page for pySide2 https://wiki.qt.io/PySide2 But I am unable to see a list of pySide2's available modules? 

The first one is generated and hosted by some domain. I didn't find anyone hosting the built pyside2 docs . I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAOOm49S-ar29yO9RLmd1rywZpe1f8s0dbgx%2BLZUHAbe%3Da_fBVg%40mail.gmail.com.

Deke Kincaid

unread,
Oct 19, 2017, 1:47:53 PM10/19/17
to python_in...@googlegroups.com
I was replying to Justin’s comment:

>>I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch

On Thu, Oct 19, 2017 at 08:37 Marcus Ottosson <konstr...@gmail.com> wrote:
Are you saying the docs for PySide2 is on qt-project.org? Where, exactly? :S

On 19 October 2017 at 15:15, Deke Kincaid <dekek...@gmail.com> wrote:
Pyside is now maintained by the qt company, so the builds are now all on their qt-project.org code site.
On Wed, Oct 18, 2017 at 13:14 Justin Israel <justin...@gmail.com> wrote:
On Thu, Oct 19, 2017 at 8:09 AM jettam <justin...@gmail.com> wrote:
This page shows me all the modules for  pySide https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/index.html  

I have found this page for pySide2 https://wiki.qt.io/PySide2 But I am unable to see a list of pySide2's available modules? 

The first one is generated and hosted by some domain. I didn't find anyone hosting the built pyside2 docs . I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBs0RY%3DUStW8Y15Hjwqd1VHnQEHBv4v5A7Eh8eoWuQr7Q%40mail.gmail.com.

Marcus Ottosson

unread,
Oct 19, 2017, 2:25:59 PM10/19/17
to python_in...@googlegroups.com
Ah, so you were. Sorry about that, I'm reading it from my mailbox as one single thread.

On 19 October 2017 at 18:47, Deke Kincaid <dekek...@gmail.com> wrote:
I was replying to Justin’s comment:

>>I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch

On Thu, Oct 19, 2017 at 08:37 Marcus Ottosson <konstr...@gmail.com> wrote:
Are you saying the docs for PySide2 is on qt-project.org? Where, exactly? :S

On 19 October 2017 at 15:15, Deke Kincaid <dekek...@gmail.com> wrote:
Pyside is now maintained by the qt company, so the builds are now all on their qt-project.org code site.
On Wed, Oct 18, 2017 at 13:14 Justin Israel <justin...@gmail.com> wrote:
On Thu, Oct 19, 2017 at 8:09 AM jettam <justin...@gmail.com> wrote:
This page shows me all the modules for  pySide https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/index.html  

I have found this page for pySide2 https://wiki.qt.io/PySide2 But I am unable to see a list of pySide2's available modules? 

The first one is generated and hosted by some domain. I didn't find anyone hosting the built pyside2 docs . I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAOOm49TpvUfr-ipykuo_07JGSa66E57hJaJkbfN8ZJ-pbdXGgg%40mail.gmail.com.

Justin Israel

unread,
Oct 19, 2017, 2:42:51 PM10/19/17
to python_in...@googlegroups.com


On Fri, Oct 20, 2017, 6:47 AM Deke Kincaid <dekek...@gmail.com> wrote:
I was replying to Justin’s comment:

>>I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch

This comment was exactly referring to the build of the docs. Where do they host the build of the docs on their site? 

Deke Kincaid

unread,
Oct 19, 2017, 7:39:55 PM10/19/17
to python_in...@googlegroups.com
ok, I thought you were talking about the software itself.

On Thu, Oct 19, 2017 at 11:42 AM, Justin Israel <justin...@gmail.com> wrote:


On Fri, Oct 20, 2017, 6:47 AM Deke Kincaid <dekek...@gmail.com> wrote:
I was replying to Justin’s comment:

>>I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch

This comment was exactly referring to the build of the docs. Where do they host the build of the docs on their site? 

On Thu, Oct 19, 2017 at 08:37 Marcus Ottosson <konstr...@gmail.com> wrote:
Are you saying the docs for PySide2 is on qt-project.org? Where, exactly? :S

On 19 October 2017 at 15:15, Deke Kincaid <dekek...@gmail.com> wrote:
Pyside is now maintained by the qt company, so the builds are now all on their qt-project.org code site.
On Wed, Oct 18, 2017 at 13:14 Justin Israel <justin...@gmail.com> wrote:
On Thu, Oct 19, 2017 at 8:09 AM jettam <justin...@gmail.com> wrote:
This page shows me all the modules for  pySide https://deptinfo-ensip.univ-poitiers.fr/ENS/pyside-docs/index.html  

I have found this page for pySide2 https://wiki.qt.io/PySide2 But I am unable to see a list of pySide2's available modules? 

The first one is generated and hosted by some domain. I didn't find anyone hosting the built pyside2 docs . I'm not sure why the pyside project doesn't host their own active build of the 2.0 branch.


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2EseY19gfF%3DiFzBPaMV50BhoErxRPpQGaxEK%2BF1E8JOg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages