0
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_LOCATIONMaya 根文件夹
  3. site-packages附加地址sys.path

dll文件在此地址中%:\Program Files\Autodesk\Maya2014\Python\DLLs 我将环境设置为上面的地址,但仍然出现相同的错误

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

我需要一个准确的指南来解决这个错误

4

1 回答 1

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')

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

资源。

于 2013-09-02T06:13:01.827 回答