如何为Maya使用外部解释器?

时间:2013-07-06 05:58:49

标签: python dll maya

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import maya.standalone
ImportError: No module named maya.standalone

这是我的条件:

  1. Maya提供的Python版本
  2. 环境变量PYTHONPATH设置为sitepackages文件夹,MAYA_LOCATION设置为Maya根文件夹
  3. site-packages地址附加到sys.path
  4. dll个文件位于此地址%:\Program Files\Autodesk\Maya2014\Python\DLLs 我将环境设置为上面的地址并仍然得到相同的错误

    为什么我要将PYTHONPATH环境设置为%:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages

    我需要一个解决此错误的确切指南

1 个答案:

答案 0 :(得分:3)

以下代码可能会帮助您将标准Python 2.6作为与Maya挂钩的独立外部解释器。

################################################################

import os
import sys

#======================================================#
#THESE ARE THE MISSING STUFF WHEN RUNNING pythonw.exe
#======================================================#

os.environ["MAYA_LOCATION"] = "C:\Program Files\Autodesk\Maya2014"
os.environ["PYTHONHOME"]    = "C:\Program Files\Autodesk\Maya2014\Python"
os.environ["PATH"] = "C:\\Program Files\\Autodesk\\Maya2014\\bin;" + os.environ["PATH"]

sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib\site-packages\setuptools-0.6c9-py2.6.egg")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib\site-packages\pymel-1.0.0-py2.6.egg")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib\site-packages\ipython-0.10.1-py2.6.egg")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib\site-packages\ply-3.3-py2.6.egg")                         
sys.path.append("C:\Program Files\Autodesk\Maya2014\\bin\python26.zip")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\DLLs")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib\plat-win")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib\lib-tk")
sys.path.append("C:\Program Files\Autodesk\Maya2014\\bin")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python")
sys.path.append("C:\Program Files\Autodesk\Maya2014\Python\lib\site-packages")

import maya.standalone
maya.standalone.initialize(name='python')

################################################################

Source.