How to use an external interpreter for Maya?

∥☆過路亽.° 提交于 2020-01-06 07:26:28

问题


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

This is my condition:

  1. Python version provided by Maya
  2. Environment variable PYTHONPATH set to sitepackages folder and MAYA_LOCATION to Maya root folder
  3. site-packages address appended to sys.path

dll files are here in this address %:\Program Files\Autodesk\Maya2014\Python\DLLs I set the environment to address above and still got the same error

Why should I set PYTHONPATH environment to %:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages?

I need an exact guide for solving this error


回答1:


The following code might help you get a standard Python 2.6 as a standalone external interpreter hooked with 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.



来源:https://stackoverflow.com/questions/17500157/how-to-use-an-external-interpreter-for-maya

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!