Problems loading Python scripts / plugins in Maya 2013

Problems loading Python scripts / plugins in Maya 2013

Anonymous
Not applicable
2,031 Views
5 Replies
Message 1 of 6

Problems loading Python scripts / plugins in Maya 2013

Anonymous
Not applicable
I had written a plugin consisting of a few Maya DG nodes as well as some python scripts. The various python methods are split across several files (one .py for each DG node, one .py for methods/functions shared by the DG nodes implentations, finally one .py file with the load/unload routines that register each of the plugin DG nodes).

I first developed this plugin for Maya 2009, and the code and its "deployment" (I use the term loosely) worked fine for me and a client/user of the plugin. When I upgraded to Maya 2012 (I skipped 2010/2011 initially), the same deployment no longer loads from the Plugin Manager (or with loadPlugin). The script editor output isn't very revealing:

// Error: SyntaxError: invalid syntax //
// Warning: Failed to run file: D:/Users/Paul/Documents/Maya/pythonPlugins/ImageG/imageG.py //

(No line numbers where errors are encountered, specific type of error)

I've likewise had no luck in Maya 2013 or Maya 2011 (gotten off subscription).

Each of the .py files for the plugin reside in "D:\Users\Paul\Documents\Maya\pythonPlugins\ImageG". A .py while with shared functions lives in "D:\Users\Paul\Documents\Maya\pythonPlugins\ImageG\scripts"

I'll note as well that I have a downloaded plugin from the Internet that is confined to one file (cvShapeInverter) that does load correctly in Maya 2011, 2012, and 2013

Any ideas what's going on or how to proceed ?

This is my Maya.env which worked for 2009:

<<<<<Start Maya.env>>>>
# Set a base directory location for plugins and scripts
IMAGE_G_PLUGIN_HOME = D:\Users\Paul\Documents\Maya\pythonPlugins\ImageG
CV_SHAPE_INVERTER_PLUGIN_HOME = D:\Users\Paul\Documents\Maya\pythonPlugins\cvShapeInverter

MAYA_PLUG_IN_PATH = C:\Program Files\Autodesk\Maya2013\devkit\plug-ins\scripted\;&#xIM;AGE_G_PLUGIN_HOME%;&#xC;V;_SHAPE_INVERTER_PLUGIN_HOME%;

# Add the location for ImageG AE Templates
MAYA_SCRIPT_PATH = &#xMA;YA_SCRIPT_PATH%;&#xIM;AGE_G_PLUGIN_HOME%\AETemplates;

PYTHONPATH = &#xIM;AGE_G_PLUGIN_HOME%\scripts;&#xIM;AGE_G_PLUGIN_HOME%;&#xC;V;_SHAPE_INVERTER_PLUGIN_HOME%\scripts;


<<<<< End Maya.env>>>

Thanks,

Paul
0 Likes
2,032 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
A little help anyone ?

Python scripting is essentially broken for me in Maya. I had a set of working Python plugins and libraries developed under Maya 2009. Once I tried using them in almost any later version of Maya... 2011, 2012, 2013 (I don't currently have 2010 installed), the plugins fail to load, and/or the modules fail to import.

After additional investigation on my part, it appears the failure for the plugin occurs when it attempts to import a module. With the correct path to that module in a maya.env file, Maya is able to find the proper python source file. However any attempt to import the module results in this error:

import kuperExport
# Error: SyntaxError: invalid syntax #

Note I'm getting no hints or further information as to the line number or description of the syntax error.

Reiterating, the same set of python files will load and function correctly in Maya 2009.

I create an simpler kuperExportD.py file consisting only of:
def helloWorld:
print "hello world"

And I still get "invalid syntax" error above.

This happens identically whether I'm running Maya 2011, 2012, or 2013. And it works in Maya 2009. I suspect something is screwy, but I have no idea how to pinpoint it further or fix it.
And as mentioned in the initial post. A piece of downloaded code does work.

However in Maya 2009, the exact same code loads and/or imports and works.
0 Likes
Message 3 of 6

kanenas_0
Explorer
Explorer
I can't claim any deep knowledge of Python which I consider the equivalent of DLL hell under older Windows versions. All these incompatible versions that float around is a disgrace to elegant coding.

Does your Maya.env posted above really looks like this? It has these strange entries with # characters and such?

It brings to mind the problems I had starting some plugin under Maya 2012.
My Maya.env looked fine but environment variables got messed up during execution.

Instead of repeating myself, have a look at the thread I posted describing the problem and its solution. You might be the victim of something similar.

http://area.autodesk.com/forum/autodesk-maya/installation---hardware---os/mayascriptpath-parser-erro...

Good luck.
0 Likes
Message 4 of 6

Anonymous
Not applicable
Thank you for your reply.

I don't think my Maya.env has the #symbols. I copied and pasted that from an open editor; When I specified it as code, I think it may have converted '$' to '&#x'.

What is more troubling/curious/annoying is that my error doesn't appear related to the path variables. Python seems to find the files, it just barfs when trying to interpret them. And it is only happening with my personally written python files. A non-commercial plugin, which is likewise placed into a folder separate from the default location and included in the plugin/python path, loads and interprets correctly.

Hopefully someone from Autodesk will read this and perhaps have some additional insight. All I can think to try right now is obtaining and installing Maya 2010 and see if I experience the problem there.

Thanks again,

Paul
0 Likes
Message 5 of 6

Anonymous
Not applicable


I first developed this plugin for Maya 2009, and the code and its "deployment" (I use the term loosely) worked fine for me and a client/user of the plugin. When I upgraded to Maya 2012 (I skipped 2010/2011 initially), the same deployment no longer loads from the Plugin Manager (or with loadPlugin). The script editor output isn't very revealing:

// Error: SyntaxError: invalid syntax //
// Warning: Failed to run file: D:/Users/Paul/Documents/Maya/pythonPlugins/ImageG/imageG.py //

(No line numbers where errors are encountered, specific type of error)



I can now get more useful descriptions of the errors, if I switch on History->"Show Stack Trace" in the Script Editor. It seems the "Show Stack Trace"(SST) checkbox had no effect on Python panels in Maya 2009; effectively, you always got a stack trace. By some version, SST started affecting Python panels as well.
0 Likes
Message 6 of 6

Anonymous
Not applicable
Once I knew how to turn the stack trace on in the Script Editor, I was quickly able to determine my problem.

With more verbose errors, I got the following:

import kuperExport

# Error: invalid syntax
# Traceback (most recent call last):
# File "<maya console>", line 1, in <module>
# File "D:\Users\Paul\Documents\Maya\pythonPlugins\kuperExport\scripts\kuperExport.py", line 238
# return plugDistance.as(units)
# ^
# SyntaxError: invalid syntax #


Sometime after Maya 2009, the MDistance class must have been changed, making the ".as" method obsolete. I'm guessing this done to avoid confusion with the Python built-in operator "as" for importing modules into a namespace, e.g.

import OpenMaya as om

So yay! Problem solved, though quite frustrating especially when I discovered this in the middle of a shoot prep.

Paul
0 Likes