# Trying to find the best way to implement platform bindings for qt5

#1

When i’m starting pyblish-qml in maya 2017 on windows i’m getting error, it couldn’t find qwindows.dll plugin.
I’ve found your issue @marcus here https://github.com/pyqt/python-qt5/issues/2
But i’m still stuck with this problem and i can’t find a good way to solve it.
Could you help me ?

#2

Hi @sega,

Give Python 3.6 a try, you can then pip install PyQt5, host the installation somewhere central and point QML to it via environment variables found on the QML GitHub page. I’m not at a computer at the moment, but can post a more detailed example if you are having trouble.

#4

I have to use maya’s python ( mayapy ). It is Python 2.7.11 (default, Dec 21 2015, 22:48:54) [MSC v.1700 64 bit (AMD64)] on win32.
Is there any way to tell maya about qwindows.dll ?

#5

In that case you’ll have to build PyQt5 yourself, as python-qt5 was built against the python.org version of Python 2.7, MSC v.1500 64-bit (AMD64).

It would also mean you’d have to build PyQt5 for each host you are looking to use pyblish-qml with, such as Nuke and Houdini.

I would recommend you consider using an external Python, independent of Maya.

#6

Thank you @marcus.
That was my fault, i installed python-qt5, but i didn’t read manual https://github.com/pyqt/python-qt5/wiki/Installation.
Firstly i had to do this:
$cd c:\path\to\python-qt5$ python -c “import util;util.createqtconf()”

#7

QML version is AWESOME !
One more question: Is it possible to run pyblish-qml with maya2013 ? I guess its a stupid question but anyway = )

#8

Yes, it should run on any version of Maya with support for Python 2.6 and above. Let me know if you encounter any issues.

#9

There is my UserSetup.py file:

import pyblish.api
pyblish.api.register_host("maya")
pyblish.api.register_gui("pyblish_qml")
import pyblish_maya
pyblish_maya.setup()
from pyblish_starter import install, maya
install(maya)
from pyblish_qml import api
api.register_python_executable("C:/Python27/python.exe")


It fails on line: from pyblish_qml import api

Traceback (most recent call last):
File "C:/Users/sega/Documents/maya/2013-x64/prefs/scripts\userSetup.py", line 19, in <module>
from pyblish_qml import api
File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pyblish_qml-1.1.0-py2.6.egg\pyblish_qml\api.py", line 1, in <module>
from .host import (
File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pyblish_qml-1.1.0-py2.6.egg\pyblish_qml\host.py", line 8, in <module>
from . import ipc, settings, _state
File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pyblish_qml-1.1.0-py2.6.egg\pyblish_qml\ipc\__init__.py", line 1, in <module>
from . import client, server, service
File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pyblish_qml-1.1.0-py2.6.egg\pyblish_qml\ipc\client.py", line 178
_byteify(key): _byteify(value) for key, value in data.items()
^
SyntaxError: invalid syntax


I think i do something wrong.

#10

Ah, that’s a Python 2.6 incompatibility.

This won’t work on 2.6

# Python 2.7
{key: value for key, value in [("a", "b")]}

# Python 2.6
dict((key, value) for key, value in [("a", "b")])


Try replacing…

# This
_byteify(key): _byteify(value) for key, value in data.items()

# With this
(_byteify(key), _byteify(value)) for key, value in data.items()


Note the removed : and added parentheses.

#11

Yeah, didnt see curly bracers. Got some same errors, i will try to replace them.

#12

Ok, now i get this thing:

Using Python @ 'C:/Python27/python.exe'
Using PyQt5 @ 'C:/Python27/Lib/site-packages/python-qt5'
One or more of your environment variable values are not <str>

# Traceback (most recent call last):
#   File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pyblish_qml-1.1.0-py2.6.egg\pyblish_qml\host.py", line 112, in show
#     server = ipc.server.Server(service)
#   File "C:\Program Files\Autodesk\Maya2013\Python\lib\site-packages\pyblish_qml-1.1.0-py2.6.egg\pyblish_qml\ipc\server.py", line 152, in __init__
#     self.popen = subprocess.Popen(**kwargs)
#   File "C:\Program Files\Autodesk\Maya2013\bin\python26.zip\subprocess.py", line 650, in __init__
#   File "C:\Program Files\Autodesk\Maya2013\bin\python26.zip\subprocess.py", line 855, in _execute_child
#     startupinfo)

TypeError: environment can only contain strings

#13

Try finding which one it is, you can do something like this.

import os
for key, value in os.environ.items():
if not isinstance(value, str):
print("%s is not str" % value)


This happens when you modify your environment using anything other than str keys or values. For example.

os.environ[u"NOT_STR"] = 5


#14

I got list of variables and there are all variables for maya. I think this happens because of windows OS has russian language and environs using unicode ( but paths have latin letters only ).
When i started pyblish-qml in maya2017 there were no errors like this.

#15

I fixed this problem by using:

str_environ = copy.deepcopy(environ)

for key in str_environ:
str_environ[str(key)] = str(str_environ[key])


in server.py file

#16

Finally got it, agrs list in server.py _listen() also has to be changed by converting unicode values to str:

def convert(data):
if isinstance(data, basestring):
return str(data)
elif isinstance(data, collections.Mapping):
return dict(map(convert, data.iteritems()))
elif isinstance(data, collections.Iterable):
return type(data)(map(convert, data))
else:
return data
`

args = convert(args)