问题
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:
- Python version provided by Maya
- Environment variable
PYTHONPATH
set tositepackages
folder andMAYA_LOCATION
to Maya root folder site-packages
address appended tosys.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