PDA

View Full Version : Cannot run userSetup.py (??)


kanenas
01-12-2013, 10:02 PM
Hello.

This is a 2-part question (that might be related to my problem).

1)
Could anybody possibly guess why this script refuses to run?
This is for Maya 2012 SP2 (and 2013 SP2) x64 under Windows 7.

I recreated the Maya.env after some installer trashed it and somehow I can't get this script to run anymore.

The only relevant line in Maya.env is:
PYTHONPATH=c:/Users/Terry/Documents/maya/2012-x64/scripts/Python/userSetup_configs
(inside this folder I have the userSetup.py).

userSetup.py blanks PYTHONPATH, adds a couple of custom entries, and loops/adds some folders that I specify in two system environment variables.

Everything loads up fine, PYTHONPATH and sys.path are initialized, but the folders in them are the standard ones added normally. None of the ones in userSetup.py shows up.

By the way, there are no other userSetup.py files anywhere in the computer.

2)
There are references all over about appending entries to PYTHONPATH in Maya.env like so:

PYTHONPATH=%PYTHONPATH%;some folders;another folder

In my system %PYTHONPATH% doesn't get expanded anymore (I'm almost sure it was working before).
If I do a getenv on it within Maya, I get the line unchanged:
%PYTHONPATH%;some folders;another folder

It looks like either some script processor is misbehaving or you just cannot modify this variable in Maya.env. Come to think of it, don't system environment variables have priority over Maya.env (except 4-5 Maya variables maybe)?


Thanks in advance for any suggestions.

kanenas
01-13-2013, 08:09 AM
I'm adding this separately in order to keep the original post readable.

On question 1:

I resolved it by just moving the userSetup.py two levels up (into \scripts).
This is scanned by default so the file was found. It would still be nice to know how to do like in my original setup.

This gave me another problem, that I figured out without understanding the logic behind it.
At the end of this script, after looping through my system variables and setting up the PYTHONPATH and site, I add a couple of extra folders into sys.path.

import sys
sys.path.append("G:\Program Files\Autodesk\MayaBonusTools2012\python")
sys.path.append("G:\MyScriptsl\2012\win64\scripts")

The first line gets loaded, the second one gives a type error on the parameter passed.
If I change it to forward slashes:
sys.path.append("G:/MyScriptsl/2012/win64/scripts")
it works!!!

Why doesn't it complain on the first line too?

djx
01-13-2013, 12:24 PM
Why doesn't it complain on the first line too?
Luck? Keep in mind that the \ character in a python string has special meaning depending on the character that follows it. Probably one you would already know is "\n" for new-line. There are many others. In this case, my guess is that \201 is being treated as some escape code for some weird ansii character and an incorrect path is being appended.
You could prefix your string with r, to tell python to treat it as a raw string
sys.path.append(r"G:\MyScriptsl\2012\win64\scripts")
or use double \\, but I would just do what you already did and use /

David

kanenas
01-13-2013, 03:29 PM
Thanks Dave.
It makes perfect sense.

I better remember to always use forward slashes for all Maya variables. PYTHONPATH picks stuff from left and right and you never know.

CGTalk Moderation
01-13-2013, 03:29 PM
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.