Search code examples
pythonmaya

Change Python version in Maya


I'm trying to change the version of python within maya. Specifically, I want maya (maya 2013) script editor to use python2.7 and all other packages/modules attached to that version. I also want to be able to import pymel and maya from eclipse.

I've tried following this response but no luck. Maya still points to its default version.

From python, i try to import pymel with

import pymel.core as pm

and I get an error that reads

File "<stdin>", line 1, in <module>   File
 "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymel/core/__init__.py",
 line 6, in <module>
    import pymel.versions as _versions   File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pymel/versions.py",
 line 12, in <module>
    from maya.OpenMaya import MGlobal  as _MGlobal ImportError: Bad magic number in
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/maya/OpenMaya.pyc

Thanks in advance.


Solution

  • The method described in your link does work, however you have to point Python to to Maya's Python's DLLs and site-packages folder via the global PYTHONPATH variable. I successfully changed it to 2.7 and imported PyMEL by setting the following.

    PYTHONPATH=$PYTHONPATH;C:\Program Files\Autodesk\Maya2013\Python\DLLs;C:\Program Files\Autodesk\Maya2013\Python\Lib\site-packages
    

    Just tailor that for Linux or Mac, whichever, and it should do the trick. Not much is actually needed except for assigning a PYTHONHOME var to the version of Python you want to use.