CAN I USE PYTHON 2 IN MAYA 2022?
Reece Taylor, London
Antony Ward replies
With the release of Maya 2022, Autodesk finally gave us something we have been wanting for a while now, and that is access to Python 3. It seems like we have been working with Python 2 for such a long time now, so finally getting access to the newer version is certainly a bonus to those of us who have upgraded.
However, while a lot of us are seamlessly transitioning to Python 3, many technical artists just aren’t ready to take the leap just yet, and I don’t blame them. Over the years we have amassed a library of numerous scripts and tools, all written in Python 2, so the idea of having to go through them all to update them is quite daunting – but does this mean that those of us who are clinging to Python 2 are destined to never move onto newer versions of Maya?
Well Autodesk has considered this and given us a few options which will let us launch Maya 2022 with Python 2 instead of 3 (although these are only currently available to Windows and Linux users).
The first is a new -pythonver flag. You can use this to launch Maya from a command line, simply adding -pythonver 2 after the executable. You can also use this flag in the Windows shortcut too for a much simpler solution. Next to the Target field where you have the link to the Maya executable file, add the flag to the end after the quotation mark, like this:
“C:\program Files\autodesk\maya2022\bin\maya.exe” -pythonver 2
The second way is to set the MAYA_ PYTHON_VERSION environment variable. You can do this from the command window, while also launching Maya with this code, which could also be used as a batch file:
set MAYA_PYTHON_VERSION=2 “C:\program Files\autodesk\maya2022\bin\maya.exe”
So those are a couple of options for you which will enable you to continue working with Python 2, however I would recommend that you consider moving over to Python 3 eventually.