Closed shunjiAdsk closed 1 year ago
This is the same issue noted in #445
This also happens with AELoader.load() method in lib/python/site-package/pymel/core/uitypes.py:
@staticmethod
def load(modname, classname, nodename):
mod = __import__(modname, globals(), locals(), [classname], -1)
For details, please see https://forums.autodesk.com/t5/maya-programming/did-maya-2022-nodes-template-change-python/td-p/10494560
We just stumbled over this as well while deploying PyMel 1.2.0 for Maya 2022. (→ which is the first Maya version with Python 3 on our side.)
This issue and PR #445 seem to define and deal with the problem we encountered.
I'm not sure if simply calling __import__
with level=0
might not have any other unintended side effects – I haven't looked deep enough into it to have an opinion on this yet...
The "What's new in Python 3.3" document seems to suggest a switch to importlib.import_module()
instead.
@chadrik, is there any plan or ETA to look into this and merge a python 3 compatible solution into the next release soon?
I think that PyMel is an essential part of developing for Maya, and it should be fully Python 3 compatible.
Thanks in advance for the feedback, Martin
This is fixed and will be in the next release, coming soon.
When is the next release?
This code prints
# Error: level must be >= 0
with Python3 (Maya2022).There is
__import__
of toPyType.toGivenClass() in pymel/internal/factories.pyThe negative value (-1) is not compatible with Python3 now. What's New In Python 3.3
This will work with "0" instead of "-1", but I'm not sure this is a reasonable change.