如何在Maya 2013中更改python版本? [英] How do I change the python version in Maya 2013?

查看:197
本文介绍了如何在Maya 2013中更改python版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在Maya 2013中编写一个Python脚本,该脚本使用SWIG包装的pyd库,该库是使用Python 2.7编译的.我无法在Maya绑定到的Python 2.6.4中重建pyd.玛雅人当然会给出这个错误

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. # 

如何更改它,以便Maya使用Python 2.7?我已经尝试修改普通的(PYTHON_PATH,PYTHONHOME等)环境变量,但没有成功.

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.

推荐答案

Maya不使用您安装的Python,而是使用软件随附的自己的2.6版本的python.

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

但是,可以通过设置PYTHONHOME环境变量来更改它.以下文章介绍了如何执行此操作以及如何检查其设置是否正确:

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:

在Maya中选择Python

基本上,该文章可以归纳为3个步骤:

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

  1. 创建一个环境变量PYTHONHOME并将其设置为指向 所需的Python版本(例如C:\ Python27).
  2. 从"MayaDirectory" \ Python \ Lib \ site-packages中复制文件(例如C:\ Program Files(x86)\ Autodesk \ Maya2013 \ Python \ Lib \ site-packages)并将其粘贴到"PYTHONHOME" \ Lib \ site-packages(例如C:\ Python27 \ Lib \ site-packages).
  3. 重新启动Maya,看看一切正常!您可以通过运行(从Maya的脚本编辑器"中)检查正在使用的Python:

  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

请特别注意第二步,本文强调了在更改环境变量后如何使Maya的库工作.请注意,如果未正确完成此最后一步,则打印语句可能会开始出现在输出窗口"而不是脚本编辑器"中.

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.

我已经测试了链接文章的步骤,并且一切正常.版本更改适用于Python 2.6和Python 2.7!但是,我还没有进行全面的测试以了解Python API的所有方面是否都适用于2.7.

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.

这篇关于如何在Maya 2013中更改python版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆