一半君的总结纸

听话只听一半君

如何让Maya使用外部的Python interpreter

人肉备份自StackOverflow : How do I change the python version in Maya 2013?

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).
    (其实这里你把maya的site-packages路径加到PYTHONPATH里也一样)
  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.

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: