3

I am aiming to write a python script in Maya 2013 that uses a SWIG wrapped pyd library which is compiled using Python 2.7. I cannot rebuild the pyd in Python 2.6.4 which is the version that Maya is bound to. Maya of course then 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 have already tried to tinker with the usual (PYTHON_PATH, PYTHONHOME, etc) environment variables to no success.

vokuheila
  • 185
  • 2
  • 11

1 Answers1

4

Maya doesn't use your installed Python but rather its own 2.6 version of python which is included with the software.

However, it's possible to change that by setting the PYTHONHOME environment variable. The following article explains how to do that and how to check that it's setup correctly:

Choose Python Inside Maya

Basically, the article can be summed up into 3 steps:

  1. Create an environment variable PYTHONHOME and set it to point to the version of Python you want (e.g. C:\Python27).
  2. Copy the files from your "MayaDirectory"\Python\Lib\site-packages (e.g. C:\Program Files (x86)\Autodesk\Maya2013\Python\Lib\site-packages) and paste them in "PYTHONHOME"\Lib\site-packages (e.g. C:\Python27\Lib\site-packages).
  3. Restart Maya and see if everything works! You can check which Python is being used by running (from Maya's 'Script Editor'):

    import sys
    print sys.prefix
    

Pay special attention to the 2nd step where the article underlines how to make Maya's libraries work after you change your environment variable. Note that print statements might start appearing in your 'Output Window' instead of the 'Script Editor' if you haven't done this last step correctly.

I have 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 extensively to know whether or not all aspects of the Python API work with 2.7.