How do I change python version in Maya 2013?

I am about to write a python script in Maya 2013 that uses the SWIG-wrapped pyd library that is compiled using Python 2.7. I am unable to rebuild pyd in Python 2.6.4, which is the version that maya binds to. Maya of course gives this error

Module use of python27.dll conflicts with this version of Python. # 

      

How can I change it so that Maya uses Python 2.7? I've already tried to rewrite the usual (PYTHON_PATH, PYTHONHOME, etc.) environment variables with no success.

+3


source to share


1 answer


Maya is not using your installed Python, but rather its own version of python version 2.6 that comes with the software.

However, this can be changed by setting the PYTHONHOME environment variable. The following article explains how to do this and how to check if the configuration is correct:

Select Python Inside Maya

Basically, the article can be summarized in 3 steps:



  • Create an environment variable PYTHONHOME and set it to the version of Python you want (for example, C: \ Python27).
  • Copy files from "MayaDirectory" \ Python \ Lib \ site-packages (for example, C: \ Program Files (x86) \ Autodesk \ Maya2013 \ Python \ Lib \ site-packages) and paste them into "PYTHONHOME" \ Lib \ site -packages (for example, C: \ Python27 \ Lib \ site-packages).
  • Restart Maya and see if everything works! You can check which Python is being used to run (from Maya 'Script Editor'):

    import sys
    print sys.prefix
    
          

Pay special attention to the second step, in which the article highlights how to get the May libraries to work after changing the environment variable. Note that print statements may appear in your "Output Window" instead of the "Script Editor" if you haven't done this last step correctly.

I tested the steps of the linked article and everything worked correctly. The version change worked for both Python 2.6 and Python 2.7! However, I haven't tested everything to see if all aspects of the Python API work with 2.7.

+4


source







All Articles