Pymel - python and mel working together

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2008
pymel installation error

Hi,

How is it possible to have pymel running in python 2.4. Correct me if I am wrong. I think all maya commands can be run on a python shell using pymel. If I am correct. Then I try install pymel. No problem - it loads. Now I try the command

from pymel import * and boom I get the following error.


BRgds,

kNish

IDLE 1.1.2
>>> from pymel import *
Unable to determine which verson of Maya should be initialized, trying for Maya.env in C:\Documents and Settings\knish\maya
PYTHONPATH set to value C:\Program Files (x86)\Autodesk\Python\Lib\site-packages

Traceback (most recent call last):
File "<pyshell#0>", line 1, in -toplevel-
from pymel import *
File "C:\Program Files (x86)\Autodesk\Python\Lib\site-packages\pymel\__init__.py", line 506, in -toplevel-
assert util.mayaInit()
AssertionError
>>>
 
  01 January 2008
hi kNish,
are you using mayapy to launch the interpreter? this little script is found in the maya bin directory and ensures that certain environment variables are set which are necessary for maya's modules to import correctly.

it's a little different on each os. here's what it looks like on osx:

 #path=`dirname $0`
 path=/Applications/Autodesk/maya8.5/Maya.app/Contents/bin/
 pythonhome=$path/../Frameworks/Python.framework/Versions/Current
 export PYTHONHOME=$pythonhome
 export DYLD_LIBRARY_PATH=$path/../MacOS:$DYLD_LIBRARY_PATH
 export DYLD_FRAMEWORK_PATH=$path/../Frameworks:$DYLD_FRAMEWORK_PATH
 export MAYA_LOCATION=$path/..
 export MAYA_NO_BUNDLE_RESOURCES=1
 exec $pythonhome/Resources/Python.app/Contents/MacOS/Python "$@"
 


essentially, what going on is maya is ensuring that you're using its own copy of python and that the core maya libraries can be found.


a quick test to see if the problem is on the pymel side or on the interpreter setup side is to execute this code


 import maya.standalone
 maya.standalone.initialize(name="python")
 import maya.cmds as cmds
 cmds.about(version=True)
 


if that works, then pymel should work. pymel does this setup for you when you import it and it also attempts to find your Maya.env and parse that as well. however, it cannot do this unless the environment variables mentioned in mayapy (os specific) are set.

-chad
 
  09 September 2008
I'm new to all this scripting but slowly working my way thou all the setup stuff. I would love to see a step by step list on how to install, and test that it works correctly. Even the maya manual is very limited on this.

Its hard to get into scripting when there are so many bumps on the road. Thats why having check like this helps:


   import maya.standalone
   maya.standalone.initialize(name="python")
   import maya.cmds as cmds
   cmds.about(version=True)
   


Running that gives me and error from the second line.
maya.standalone.initialize(name="python")


The error I get is:


   # Error: initialize() takes no keyword arguments
   # Traceback (most recent call last):
   #   File "<maya console>", line 1, in <module>
   # TypeError: initialize() takes no keyword arguments # 
   


Funny thing is that I can run some python examples. Have had a pSphere created.
 
  09 September 2008
http://groups.google.com/group/pyth...hon-inside-maya

Seams usefull.

Last edited by mlykke : 09 September 2008 at 09:23 AM.
 
  09 September 2008
I looked around the net for examples and found:

http://linil.wordpress.com/2008/01/24/python-maya-part-1

Ofcause i soon found out that it wasn't pymel but python, but I learn one or two things in converting it to pymel:

python version:


import maya.cmds as cmds
cmds.polySphere( name = ‘bouncing’, radius = 2 )
g = -0.04
v0y = 0.8
v0x = 0.1
pos0y = 2
pos0x = 0
for itr in xrange(0,6):
	for tx in xrange(0,42):
		posy = pos0y + v0y*(tx-1) + g*(tx-1)*(tx-1)/2
		posx = pos0x + v0x*((itr*42) + tx-1)
		cmds.setKeyframe( ‘bouncing’, attribute=’translateY’, value=posy, t=(itr*42) + tx )
		cmds.setKeyframe( ‘bouncing’, attribute=’translateX’, value=posx, t=(itr*42) + tx )


pymel version:


sphere( name = 'bouncing', radius = 2 )
g = -0.04
v0y = 0.8
v0x = 0.1
pos0y = 2
pos0x = 0
for itr in xrange(0,6):
	for tx in xrange(0,42):
		posy = pos0y + v0y*(tx-1) + g*(tx-1)*(tx-1)/2
		posx = pos0x + v0x*((itr*42) + tx-1)
		setKeyframe( 'bouncing', attribute='translateY', value=posy, t=(itr*42) + tx )
		setKeyframe( 'bouncing', attribute='translateX', value=posx, t=(itr*42) + tx )
 
  02 February 2009
problem with pymel in maya8.5 64bit

hi there, i have recently installed the latest pymel, and it is successful in my maya 2008 64bit. unfortunately, not in my maya 8.5 64bit. everytime i run "import pymel" maya 8.5 gives me an error of:

import pymel
# Error: ('invalid syntax', ('C:\\Documents and Settings\\xxxxxxx\\My Documents\\maya\\8.5-x64\\scripts\\python\\pymel\\ui.py', 501, 17, ' return ret if moreButtons else (ret==yes)\n'))
# Traceback (most recent call last):
# File "<maya console>", line 1, in ?
# File "C:\Documents and Settings\oliverm\My Documents\maya\8.5-x64\scripts\python\pymel\__init__.py", line 621, in ?
# from node import *
# File "C:\Documents and Settings\oliverm\My Documents\maya\8.5-x64\scripts\python\pymel\node.py", line 17, in ?
# from core import *
# File "C:\Documents and Settings\oliverm\My Documents\maya\8.5-x64\scripts\python\pymel\core.py", line 22, in ?
# import util, factories, node, ui, io
# File "C:\Documents and Settings\oliverm\My Documents\maya\8.5-x64\scripts\python\pymel\ui.py", line 501
# return ret if moreButtons else (ret==yes)
# ^
# SyntaxError: invalid syntax #


anyone encountered this kind of problem and was able to solve it?
thanks for the help.
__________________
Behind me is INFINITE POWER.
Before me is ENDLESS POSSIBILITY.
Around me is BOUNDLESS OPPORTUNITY.
Why should i fear?
 
  03 March 2009
Yes, me too..
__________________
"There is no teacher to teach something new...he only can help us to renew the things we always knew" - Enigma
 
  03 March 2009
hi all, a brand-spankin' new version of pymel is almost ready to release. needless to say, this problem will be fixed.

-chad
 
  04 April 2009
Pymel rocks! I'm working on a number of examples converting some beginner-level poly-modeling MEL scripts to Python as a way to learn it. So far almost all the surprises have been good ones, which is amazing.

http://zoomy.net/2009/04/03/aligned...worm-in-python/
http://zoomy.net/2009/04/02/random-...mids-in-python/
http://zoomy.net/2009/04/02/random-...ocks-in-python/


Nice work Chad et al, it's been a long time since I was excited about coding.
 
  04 April 2009
Hi, I've already did all the steps shown from the manual. But when I try to test it on maya using this command :

from pymel import *

I've got this error :

from pymel import *
# Traceback (most recent call last):
# File "C:\Program Files\Autodesk\Maya8.5\Python\lib\site-packages\maya\app\python.py", line 16, in formatException
# 32, stringBuffer )
# File "C:\Python25\Lib\traceback.py", line 126, in print_exception
# lines = format_exception_only(etype, value)
# File "C:\Python25\Lib\traceback.py", line 171, in format_exception_only
# if (isinstance(etype, BaseException) or
# NameError: global name 'BaseException' is not defined


Can you help me out what's wrong with that? Is there any steps that I missed from the installation step?

Thanks a bunch...
 
  05 May 2009
this is not a pymel problem, just a general python setup issue (i'd be surprised if you can import anything at all)

don't put your system python `C:\Python25\Lib` on your PYTHONPATH when using maya, as there is a very good chance that the version is not the same as maya's internal python. in your case, maya 8.5 uses python 2.4.3 whereas your system is 2.5.x. if you have modules you want installed in maya, install them to maya's Python\lib\site-packages directory or to a shared location.

-chad
 
  05 May 2009
pymel 0.9.1 release

we just released lots of new bugfixes and features to the 0.9.x line.

among other things, it's got some slick new (searchable!) documentation and instructions on how to setup autocompletion with eclipse.

get em while they're fresh:

http://www.highend3d.com/f/4844.html
http://code.google.com/p/pymel/downloads/list

-chad
 
  08 August 2009
so, i decided its time i learned python. im trying to install pymel, and im getting stuck during the ipymel install, specifically the 5th step. i run the command 'ipymel', and the following error occurs:

ImportError: No module named _ctypes

im running python 3.1.1, which was released a few days ago. should i be using an older version of python? i attached the .txt error report it generated.

also, the files for the replacement script editor aren't there either. is this feature being pulled? sorry if these are beginner questions.
 
  08 August 2009
Originally Posted by Ironhalo: im running python 3.1.1, which was released a few days ago. should i be using an older version of python? i attached the .txt error report it generated.
.



I would recommend going back to python 2.6.

As of 2009/2010 I think they are using a custom version of 2/5/2.6. I know pymel works 100% perfectly in the maya version of python for 2009/2010 so.... ymmv but I would guess that is the underlying source of the problem.
__________________
~~ Ordinary people built the ark, specialists built the titanic.
 
  08 August 2009
I can't get Pymel running in 2010. When I try to import pymel I get this error:

 Error: AttributeError: import pymel.util as util: 'module' object has no attribute 'util' 

I copied my prefs from 2009.

Pymel is still working correctly in 2009.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:45 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.