maya python version (force open in python 3)

maya python version (force open in python 3)

bmagner888
Enthusiast Enthusiast
3,000 Views
4 Replies
Message 1 of 5

maya python version (force open in python 3)

bmagner888
Enthusiast
Enthusiast

I have a client that updated Maya 2022 to Maya 2022.4.
Now his Maya defaults to python 2.7 instead of python3.

The only way to force it to open in python 3 is by opening it through the command line.

We tried editing the maya.env file and completely removing all of his user prefs by moving the entire Documents/maya folder to his desktop.
print(sys.version) always resulted in 2.7 unless we opened through the command line.

We want it to open in python 3, NOT 2.7.  Unfortunately the only help we can find on the web is how to force it to open in 2.7. 

Any suggestions?

0 Likes
3,001 Views
4 Replies
Replies (4)
Message 2 of 5

lee.dunham
Collaborator
Collaborator

If no other option available (no idea myself) then a potential workaround - change the desktop app shortcut to include the python 3 startup arg so it starts with python 3 when launching via that shortcut (same for taskbar). Also, create a separate shortcut or .bat that does the same thing and associate .ma/.mb files to that shortcut or .bat file (for double clicking files etc).

Definitely not ideal but might be acceptable until a proper solution is found.

Message 3 of 5

bmagner888
Enthusiast
Enthusiast

we tried adjusting the shortcut but couldn't get that to work.  He found the problem,  though.  It was in his windows system environment variables.  After he fixed that sys.path entry it seems to open correctly.

0 Likes
Message 4 of 5

mishafauci
Community Visitor
Community Visitor

Have you tried to uninstall the latest python version

0 Likes
Message 5 of 5

mishafauci
Community Visitor
Community Visitor

 

To force Maya 2022.4 to open with Python 3 instead of Python 2.7, you can set the environment variable "PYTHON_EXECUTABLE" in the maya.env file. Follow these steps to accomplish this:

  1. Locate the maya.env file: The maya.env file contains environment variable settings for Maya. It should be placed in the Maya preferences directory. In this case, since you mentioned removing the user prefs and moving the Documents/maya folder to the desktop, navigate to the desktop folder where the "maya" folder is located. Inside that "maya" folder, there should be the maya.env file.

  2. Edit the maya.env file: Open the maya.env file with a text editor (e.g., Notepad, Visual Studio Code, etc.).

  3. Set the PYTHON_EXECUTABLE variable: Add the following line to the maya.env file to specify the Python 3 executable path:

 

javascript
PYTHON_EXECUTABLE = C:/path/to/your/python3.exe

 

Replace "C:/path/to/your/python3.exe" with the actual path to your Python 3 executable on your system.

  1. Save the changes: Save the maya.env file after making the necessary changes.

  2. Restart Maya: Close Maya if it's currently running, and then reopen it. Now, Maya 2022.4 should use Python 3 as the default Python interpreter.

After applying these steps, verify that the correct Python version is being used by executing the following line in Maya's Script Editor:

 

python
import sys print(sys.version)

 

It should display the version of Python 3 you specified in the maya.env file.

Keep in mind that if the PYTHON_EXECUTABLE variable is already defined in the maya.env file, make sure to update it to the correct path for Python 3. Also, double-check for any typos or errors in the path to the Python 3 executable.

By correctly setting the PYTHON_EXECUTABLE environment variable, you should be able to force Maya 2022.4 to open using Python 3 instead of Python 2.7 consistently, even without launching it through the command line.

 

 

Hope this will help you.

0 Likes