On 03/12/13 12:50, Mr. Daniel Browne wrote:
> http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=13375416&linkID=9242258
Ahh, I see, when it comes to executing /external/ python scripts, maya's
python environment variables are probably being passed on to the OS's version
of python, confusing it.
It makes sense now why an OS upgrade broke stuff; probably before the upgrade
the unix OS's version of python was the same, or close enough to maya's own
version of python that the maya python environment settings worked OK for the
OS's python.
But when you upgraded the OS, the OS's python upgraded too, perhaps to a version
of python not compatible with Maya's internal python.
So yes, that article about using maya's python os.system() call to run /external/
python scripts is somewhat relevant because any python related environment variables
maya has set to point to its own python installation would be bad for the OS's
version of python (which is probably different from maya's, after the OS upgrade)
Sounds like the simple solution is to bracket all calls to os.system() with code
that first preserves the current environment variables, then changes the PYTHONPATH
(and whatever else) to what the OS's version of python needs. e.g.
ppsave = os.environ["PYTHONPATH"]
os.system(your_cmd)
os.environ["PYTHONPATH"] = ppsave
You can probably make that a function so that you don't have to include
that code every time you use os.system().. just use your function instead.
You may find you need to change other environment variables too
(like PATH, PYTHONHOME, perhaps others).
I'd suggest comparing the output of:
printenv|sort > /tmp/unix.env
..to running that same command from /within/ maya, e.g.
os.system("printenv|sort > /tmp/maya.env")
..and then check to see what PATH and PYTHON* variables are different..
then be sure to modify those with the bracketing code defined above.
Thing is, other python commands that invoke external python scripts
might need this bracketing code as well; os.popen(), subprocess.Popen(),
just to name a few.
Arguably maya should protect us from having to worry about this
by doing the bracketing code itself.. but I can see where that would
get hairy from Autodesk's point of view..
--
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/
Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)
|