Setup Environment for Python

560 views
Skip to first unread message

illunara

unread,
Dec 3, 2012, 12:35:54 PM12/3/12
to python_in...@googlegroups.com
Hello
I follow some tutorial and setup env for Python by adding the pythonPath and mayaLocation in Environment Variables of Window

PYTHONPATH C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages\
MAYA_LOCATION C:\Program Files\Autodesk\Maya2012\

But when i run python and try to import maya.standalone, it gave me an error said that the module cound not be found. I had check the sys.path again to make sure it in there.

Anything would help, thanks

ammu0608

unread,
Dec 3, 2012, 12:45:03 PM12/3/12
to python_in...@googlegroups.com

Hi,
For importing maya standalone, the python version and maya version should be the same. Try using sys.path.append and append your maya python path. I am not in front of the system. But please give a try.

Thanks and Reagrds,
Sudeepth Patinjarayi.

Justin Israel

unread,
Dec 3, 2012, 12:50:09 PM12/3/12
to python_in...@googlegroups.com
I am not sure where this is on windows, but for other systems there is a mayapy executable. On OSX it is just a bash script that sets the proper environment variables, and then calls the python that is bundled with maya. 
If you located this file, and it is indeed a .bat file or other script on windows, you can reference it for the proper settings to set up your own python interpreter.

illunara

unread,
Dec 3, 2012, 1:22:32 PM12/3/12
to python_in...@googlegroups.com
Yup, i can import maya standalone from mayapy, but i don't know how to use one line command, its kind of complicated and inconvenient for a beginner like me. Also, i try to run some test on PyQt too, so i try to use Python IDLE to script everything down.

is this where the maya standalone's package store?

illunara

unread,
Dec 3, 2012, 1:24:54 PM12/3/12
to python_in...@googlegroups.com
I'm using Python 2.6 amd Maya 2012, both x64. What i did with window's environment variable is same with typing down sys.path.append, i just don't have to write it everytime start python. Maybe the directory is wrong?

Justin Israel

unread,
Dec 3, 2012, 1:47:20 PM12/3/12
to python_in...@googlegroups.com
What is the "one line command"? Is mayapy on windows just a script you can view? What I was suggesting is to view it and reference it to set up your environment variables properly. Once you do that, you should be able to start a normal python interpreter and do:   import maya.standalone


On Mon, Dec 3, 2012 at 10:24 AM, illunara <cb.il...@gmail.com> wrote:
I'm using Python 2.6 amd Maya 2012, both x64. What i did with window's environment variable is same with typing down sys.path.append, i just don't have to write it everytime start python. Maybe the directory is wrong?

illunara

unread,
Dec 3, 2012, 2:37:26 PM12/3/12
to python_in...@googlegroups.com
Sorry, i'm just a beginner to script so alot of thing to learn, i'm only using mayapy to do stuff when don't want to open the whole scene up.



On Tuesday, December 4, 2012 1:47:20 AM UTC+7, Justin Israel wrote:
What is the "one line command"? Is mayapy on windows just a script you can view? What I was suggesting is to view it and reference it to set up your environment variables properly. Once you do that, you should be able to start a normal python interpreter and do:   import maya.standalone


And i try to do it too, but still no go at all. It said that the specified module could not be found :(

Justin Israel

unread,
Dec 3, 2012, 2:44:35 PM12/3/12
to python_in...@googlegroups.com
I would say stick with mayapy unless you have a compelling reason to try and set it up with a standard interpreter. Just add the maya/bin location to your path. Then you have mayapy in your command path.


--

Tuan Nguyen

unread,
Dec 3, 2012, 10:14:48 PM12/3/12
to python_in...@googlegroups.com
I think you right, anyway, thank for your help :D

Sudeepth Patinjarayil

unread,
Dec 3, 2012, 11:46:31 PM12/3/12
to python_in...@googlegroups.com
Hi,
 
The below code is for maya standalone to external python. This is working for me on 2011 (32-bit) Maya. change the paths to 2012 and give a try
 
# Maya Standalone to external python
import os
import sys
#====================================================================#
#THESE ARE THE MISSING STUFF WHEN RUNNING python.exe compared with mayapy.exe
#====================================================================#
os.environ['MAYA_LOCATION'] = r'C:\Program Files (x86)\Autodesk\Maya2011'
os.environ['PYTHONHOME']    = r'C:\Program Files (x86)\Autodesk\Maya2011\Python'
os.environ['PATH'] = r'C:\Program Files (x86)\Autodesk\Maya2011\bin;' + os.environ['PATH']
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib\site-packages\setuptools-0.6c9-py2.6.egg')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib\site-packages\pymel-1.0.0-py2.6.egg')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib\site-packages\ipython-0.10.1-py2.6.egg')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib\site-packages\ply-3.3-py2.6.egg')                        
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\bin\python26.zip')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\DLLs')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib\plat-win')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib\lib-tk')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\bin')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python')
sys.path.append(r'C:\Program Files (x86)\Autodesk\Maya2011\Python\lib\site-packages')

import maya.standalone
maya.standalone.initialize(name='python')
from maya import cmds
cmds.sphere()
cmds.file(rename=r'D:\cubetemp.ma')
cmds.file(save=True)
# code compleation
 
Thanks and Regards,
Sudeepth Patinjarayil.
 
 

Tuan Nguyen

unread,
Dec 4, 2012, 2:06:30 AM12/4/12
to python_in...@googlegroups.com
Thank Sudeepth
I still get an error that its not valid win32 application. But look like we got the environment right, i will go around and find out about this :D


 
 

--

Sudeepth Patinjarayil

unread,
Dec 4, 2012, 2:22:32 AM12/4/12
to python_in...@googlegroups.com
Yea i also faced the same problem. i got it done by installing Maya and Python 32-Bit version. if possible try to install 32-bit and try. if i get any solution i will let you know.

Tuan Nguyen

unread,
Dec 4, 2012, 2:39:32 AM12/4/12
to python_in...@googlegroups.com
thank in advanced, Sudeepth XD


On Tue, Dec 4, 2012 at 2:22 PM, Sudeepth Patinjarayil <ammu...@gmail.com> wrote:
Yea i also faced the same problem. i got it done by installing Maya and Python 32-Bit version. if possible try to install 32-bit and try. if i get any solution i will let you know.

--

tex...@gmail.com

unread,
Oct 8, 2015, 2:35:16 PM10/8/15
to Python Programming for Autodesk Maya
Really old thread but thanks Sudeepth! Was a big help still.

Reply all
Reply to author
Forward
0 new messages