CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-03-2013, 12:58 AM   #1
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
Thumbs up A noob's Python/PyMel/Eclipse thread [Mac/OSX]

Hi everyone,

I am diving into learning to use Python in Maya. I have been neck-deep in it for the past few days, and I have quite a few questions. I'm starting this thread in the hopes that whatever answers I get from the community's experts will be locatable by other new users who will come after me.

A little bit on where I'm coming from: I'm fairly experienced as a character TD, and have done some character pipeline work as well. I've used MEL extensively in production for the past ten years, and I've used Python a bit in a proprietary production environment.

So I'm not brand-new to scripting, but I want to say up front that I will be asking some *really* facepalm-basic questions about Python in Maya, and about Python in general.

I think I have done due diligence so far - I have read through all of the following:

Autodesk's Python Scripting Documentation:
http://download.autodesk.com/global...n_us/index.html
(User Guide --> Scripting --> Python)

PyDev's Interpreter Configuration Docs:
http://pydev.org/manual_101_interpreter.html

The Most Excellent Eclipse IDE tutorial by Ron Bublitz:
http://www.creativecrash.com/tutori...a-maya-ide#tabs

and finally

Manish's followup tutorial:
http://www.creativecrash.com/maya/t...r-maya-commands



So let me kick this off by asking what's going on here:

import pymel.core as pm;

^^ when I execute this in the Python tab of Maya's script editor, Maya enters an infinite loop where it repeatedly warns me about plugins (the standard ones) being already loaded. I can only assume that attempting to import the pymel.core module is causing Maya to load these plugins over and over.

import maya.cmds as cmds

^^ this works fine; no errors.

Any ideas what might be causing this? Any assistance will be greatly appreciated.

Btw, here are some pertinent specs:

Mac OSX 10.6.8
Maya 2013-x64
PyMel 1.0.3

Thanks!

plumbershelper

Last edited by plumbershelper : 05-03-2013 at 06:14 AM. Reason: Making Title more accurate
 
Old 05-03-2013, 02:33 AM   #2
tswalk
Expert
 
tswalk's Avatar
portfolio
Troy Walker
USA
 
Join Date: Jan 2012
Posts: 717
on a quick search i found:

from pymel.core import *

which imports everything into the namespace..

http://download.autodesk.com/us/may...l/tutorial.html
__________________
-- LinkedIn Profile --
-- Blog --
-- Portfolio --
 
Old 05-03-2013, 03:29 AM   #3
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
Quote:
Originally Posted by tswalk
on a quick search i found:

from pymel.core import *

which imports everything into the namespace..

http://download.autodesk.com/us/may...l/tutorial.html



Thanks for the response! Unfortunately that results in the same infinite loop of loading plugins, and warnings about them already being loaded. Ultimately I have to force quit Maya.
 
Old 05-03-2013, 03:35 AM   #4
tswalk
Expert
 
tswalk's Avatar
portfolio
Troy Walker
USA
 
Join Date: Jan 2012
Posts: 717
i see,, well, if they're already loaded then it may not be necessary perhaps? sorry, i'm not a pymel person :(
__________________
-- LinkedIn Profile --
-- Blog --
-- Portfolio --
 
Old 05-03-2013, 06:12 AM   #5
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
maya.cmds vs PyMEL -and- site-package on the PYTHONPATH

Ok, here's another burning question:

My understanding is that ultimately the original Python implementation of MEL (i.e. maya.cmds) and its successor, PyMEL, drive the same gears and pull the same levers in the C++ API. They just go about it through two different syntaxes - the former somewhat python-like, the latter more so. Is this - the "same gears, same levers" part - an accurate understanding of the two packages?

Now for an Eclipse question-

Context first:
In the Ron Bublitz tutorial (1), he writes "Now that Maya comes with pymel, the included docs explain how to get it working with Eclipse." He then demonstrates a quick-setup way to get command completions, but later writes "Remember to still specify the path to the Maya "site-packages" directory on the "Libraries" path (just like the older method)."

Consulting "the included docs" above - the PyMEL installation instructions - the "Manual Method 1" section states that "...both the pymel and maya sub-directories must be on the python path, and they must come before the standard maya package in the search path. To keep things simple, we are now recommending that the top-level pymel-1.0.x directory be added to the PYTHONPATH instead of copying the pymel sub-directory."

So here's the question -
Should I take the above to mean that both the maya.cmds module and the pymel module are being placed on the PYTHONPATH, assuming I add:

/Applications/Autodesk/maya2013/Maya.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

to the PYTHONPATH for the selected interpreter in Eclipse?


Secondly, if I

import pymel as pm

in my script, can I just forgo any importation of maya.cmds?

Thanks,

plumbershelper


(1) http://www.creativecrash.com/tutori...-ide/page2#tabs
 
Old 05-03-2013, 02:04 PM   #6
djx
Where's my pony?
 
djx's Avatar
David Johnson
vfx & creature td
Melbourne, Australia
 
Join Date: Jun 2003
Posts: 3,415
Quote:
import pymel.core as pm;
when I execute this in the Python tab of Maya's script editor, Maya enters an infinite loop where it repeatedly warns me about plugins (the standard ones) being already loaded.

This is the most common way of importing pymel, but the error you are getting is not. You probably should troubleshoot, as you would normally, by removing your prefs folder and any 3rd party plugins, and custom mel or python scripts. And I would also make sure you are not specifying python paths outside of maya (in system environment variables for example). You should not get the error in a clean vanilla maya installation. Then you can start adding back your customizations, bit by bit, until you break it again.

Quote:
import pymel.core as pm
in my script, can I just forgo any importation of maya.cmds?

Well they are 2 different things. In some ways your description of their relationship to the underlying C++ is vaguely true. And it is technically possible on some level to structure some code so that pymel.core as pm is interchangeable with maya.cmds as cmds, but if you did that you would be missing the point entirely. pymel functions return node classes where as maya.cmds returns strings and string arrays. But I guess the simple answer to your question is yes, if you prefer the object oriented pymel.

David
__________________
http://www.djx.com.au
 
Old 05-04-2013, 01:50 AM   #7
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
Thanks David, I will try your suggestion for debugging.
 
Old 05-18-2013, 01:40 AM   #8
plumbershelper
New Member
portfolio
USA
 
Join Date: Feb 2013
Posts: 15
Following up here -

Previously I was having a work-stopper issue where executing

import pymel.core as pm

would cause Maya to enter an infinite loop of re-loading plugins.

After some digging around with Google, I stumbled onto the GitHub repository for PyMEL, and discovered that PyMEL is up to version 1.0.5 now. I downloaded that release, installed it, and now that bug is fixed! #happydance

I don't know what exactly changed from version 1.0.3 to 1.0.5 to fix my import problem.

Eclipse note: The 1.0.5 release of PyMEL does not include the auto-completion stubs, strangely. I have tried to contact the author of the 1.0.5 version about this, but so far have not heard anything back. I did however get autocompletion in Eclipse to work by just copying the extras/completion folder from 1.0.3 over to the 1.0.5 directory. Not the best way to solve the problem, but it seems to work.

Unfortunately, now Eclipse is throwing errors when I try to import pymel.core as pm, executing within Eclipse, using the Maya Python interpreter. When I send the same command to Maya via the command port plugin, it works fine, and I get correct results from Maya in my console view. Don't know why this should be. Here's the error I get:

File "/Users/myUserName/Documents/Eclipse_workspace/PyMELTest/hello.py", line 1, in <module>
import pymel.core as pm
File "/Applications/Autodesk/maya2013/Maya.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pymel/core/__init__.py", line 6, in <module>
import pymel.versions as _versions
File "/Applications/Autodesk/maya2013/Maya.app/Contents/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pymel/versions.py", line 12, in <module>
from maya.OpenMaya import MGlobal as _MGlobal


I'm wondering if this is some sort of issue with PyDev.

plumbershelper
 
Old 10-28-2013, 09:23 AM   #9
cvani
New Member
portfolio
Nepal
 
Join Date: Oct 2013
Posts: 2
I just set up Eclipse and when I try PyMEL, I am getting the same error. Whereas in Maya it works but not in Eclipse. If you resolved the problem then could you please share how. Thanks.
 
Old 10-28-2013, 09:23 AM   #10
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 07:08 PM.


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