Maya 2022 and Python3

Installing now taking a look whats inside.

Ah Python3, finally we can move forward. A couple of really useful nuggets that might help people get going with Maya 2022.

Autodesk are keen for people to migrate to Python3, which is totally understandable, Python2 is no longer under support and it’s time to shift, however, Maya2022 is duel boot. Python2.7 is there for those needing to migrate but in a more controlled manner. To boot in Python 2.7 run the following from the command line.

maya -pythonver 2

Also useful is the new Module handling for Python. There’s a global var MAYA_PYTHON_VERSION which is up right from the get go and can be used in your module path to redirect your boot sequence between Python2 and Python3 cuts. We’re doing this in our Module path:

+ MAYAVERSION:2022 Red9_Dev 2.0 D:/Red9_Core/Red9_Dev_P%MAYA_PYTHON_VERSION%

Autodesk are doing something similar for the USD plugin boot.

Finally if anybody wants to test out our Red9 StudioPack in 2022 there’s a new GitHub repository for the Python3 build, and our Red9 ProPack pipeline is also now Python3 compliant so ping if you’d like to test it out.

Be interesting to see how fast studios migrate to this

cheers

Mark

4 Likes

I love those Component Tags.

2 Likes

Does this mean we can use NUMPY without compiling a special MAYA version? aka find the google drive and download it from generous person.

2 Likes

Just in case you like to start Maya with Python 2.

1 Like
1 Like

Yep! I checked with the vanilla numpy and p4python packages downloaded straight from pypi and both worked with Maya 2022 out of the box.

Hopefully recompiling Python extensions for Max and Maya is a thing of the past.

1 Like

Anyone knows how to get pymel to work/install ?

Have you tried

pip install pymel

Using Python 2 in Maya 2022, I’m seeing Qt.py(0.6.9) errors in tools that worked in Maya 2017.

Trying _pyside2
# Error: line 1: AttributeError: file W:\animation-pipeline-dev\python27\lib\Qt.py line 239: 'module' object has no attribute 'QStringListModel' # 

UPDATE:
From Marcus Ottosson’s Qt.py github :

QStringListModel was moved from QtGui to QtCore in Qt5. PySide2 kept it in QtGui for a while, but have now also moved it to QtCore. (See https://bugreports.qt.io/browse/PYSIDE-614.)

This means that Qt.py also need to update to be compatible with newer versions of PySide2.

The task was closed on May 31, 2019, so it may only impact guis from Maya 2019 and earlier

We also use a lot of mGui in our UIs, which seems to suffer from the PyQt changes in 2022 as well.

even vanilla pymel UIs seem to break
# Error: line 1: ImportError: file C:\Program Files\Autodesk\Maya2022\Python27\lib\compiler\__init__.py line 31: No module named pycodegen

this is getting oddly specific to my situation, I’ll do a cleaner test of qt.py and 2022

Wow…That was…EASY?! (quite impressed …)

For anyone that wants to try , first you gotta install pip
-1 : download get-pip.py ( from here
-2 : move the file here C:\Program Files\Autodesk\Maya2022\bin
-3 : from command prompt run mayapy.exe get-pip.py
PIP is installed…
now :
-4 : go to C:\Program Files\Autodesk\Maya2022\Python37\Scripts>
-5 : run from cmds prompt , pip3.7.exe install pymel

im quite happy about this…did anyone try installing any machine learning libraries ?

Never been as easy …nice!

first you gotta install pip

@alfo - in an unmodified install of Maya 2022, pip is already installed under:
image
(Also for python27, if you switch over to that directory)

I’m curious as to why this was a required step for you. This doesn’t come installed already? (if so, that seems to be a mishap/bug! :open_mouth:) Based on a previous question, did you exclude PyMEL for Python 3 in your install?
image

This morning, I was installing pipenv. Like a standalone python interpreter, you can pass pip as a module parameter (-m) to mayapy and supply args. This is another way of doing it, without navigating to the Scripts folder to call pip, pip3 or pip3.7.exe.

image

1 Like

Hey peeps - I wrote a blog post a few weeks ago about supporting python2 and python3 in your DCC code bases.
It was something I had to do last year when Max2021 came out and there are bunch of little gotchas that I came across during the process.
Check it out here: https://techanimdad.com/2021/04/10/supporting-py2-py3-part-1/

2 Likes