userSetup.py not running on startup

4,704 views
Skip to first unread message

Aren Voorhees

unread,
Nov 24, 2015, 2:15:19 PM11/24/15
to Python Programming for Autodesk Maya
Hey everyone,

I'm trying to use the userSetup.py to do some imports whenever Maya is started up (ex. import pymel.core as pm, import maya.cmds as cmds, etc).  However I can't seem to get the file to run on Maya's startup.  I know I've done this before on a different computer without issue.  Even boiling it down to something as simple as putting: print "Hello World" in userSetup.py doesn't do anything.  

Inside of Maya I've tried doing: 

import sys


for p in sys.path:
   
print p


Of course that gives me a list of paths...I've tried putting the userSetup.py in many different of those places and still no luck.

I also tried:

print cmds.internalVar(usd=True)

and putting userSetup.py there (which I had already tried earlier, but hey, why not).

I've also tried blowing away my maya.env file to make sure that wasn't doing anything weird.  

Any ideas?

Thanks!

Robert White

unread,
Nov 24, 2015, 2:47:33 PM11/24/15
to Python Programming for Autodesk Maya
So I just tested that in Maya2016 and it seemed to work fine. Remember that anything printed in a userSetup.py will most likely end up in the output window (which is minimized by default in 2016), and not in the script editor window once Maya is done loading. This is because userSetup.py is run before the various GUI elements have actually been spun up and initialized.

Just in case, double check that the env variable MAYA_SKIP_USERSETUP_PY isn't set, and obviously that your userSetup.py is on the PYTHONPATH.

Justin Israel

unread,
Nov 24, 2015, 3:20:55 PM11/24/15
to python_in...@googlegroups.com
On Wed, Nov 25, 2015 at 8:47 AM Robert White <robert....@gmail.com> wrote:
So I just tested that in Maya2016 and it seemed to work fine. Remember that anything printed in a userSetup.py will most likely end up in the output window (which is minimized by default in 2016), and not in the script editor window once Maya is done loading. This is because userSetup.py is run before the various GUI elements have actually been spun up and initialized.

Just in case, double check that the env variable MAYA_SKIP_USERSETUP_PY isn't set, and obviously that your userSetup.py is on the PYTHONPATH.

I didn't think it had to be on the PYTHONPATH if you use one of the standard Maya location. Doesn't it just need to live in a maya "scripts" directory? Either in the "shared/scripts" or "<version>/scripts" locations?



On Tuesday, November 24, 2015 at 1:15:19 PM UTC-6, Aren Voorhees wrote:
Hey everyone,

I'm trying to use the userSetup.py to do some imports whenever Maya is started up (ex. import pymel.core as pm, import maya.cmds as cmds, etc).  However I can't seem to get the file to run on Maya's startup.  I know I've done this before on a different computer without issue.  Even boiling it down to something as simple as putting: print "Hello World" in userSetup.py doesn't do anything.  

Inside of Maya I've tried doing: 

import sys


for p in sys.path:
   
print p


Of course that gives me a list of paths...I've tried putting the userSetup.py in many different of those places and still no luck.

I also tried:

print cmds.internalVar(usd=True)

and putting userSetup.py there (which I had already tried earlier, but hey, why not).

I've also tried blowing away my maya.env file to make sure that wasn't doing anything weird.  

Any ideas?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/86384880-5b5f-4c85-b60c-669b961c308d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aren Voorhees

unread,
Nov 24, 2015, 3:24:56 PM11/24/15
to Python Programming for Autodesk Maya
I have it in: C:\Users\avoorhees\Documents\maya\2016\scripts

Although in my struggles, I've tried it lots of other places too.  Robert, MAYA_SKIP_USERSETUP_PY was not set in my maya.env file (I also tried using a blank maya.env file just in-case).  


On Tuesday, November 24, 2015 at 1:15:19 PM UTC-6, Aren Voorhees wrote:

Aren Voorhees

unread,
Nov 24, 2015, 3:53:17 PM11/24/15
to Python Programming for Autodesk Maya
Ok, an update!  

Once I started looking for my print statement in the output window as Robert suggested, I was able to work out a few issues to get things closer to working.  

So now things like
import pymel.core as pm
and 
import maya.cmds as cmds
are working, so that's progress at least!

But now, I'm trying to also make it import some of my own scripts automatically.  Something like:
import riggingTools as rt

When I run that from the script editor it works fine, but when I put that in in my userPrefs.py and run rt.someMethod() it says name 'rt' is not defined.  So for some reason it works when I import it in Maya, but does not work when I try to run it in in my userStartup.py  

Justin Israel

unread,
Nov 24, 2015, 4:14:13 PM11/24/15
to Python Programming for Autodesk Maya
Are you sure that the import isn't failing, in your userSetup.py ? Does it depend on any facilities that may not yet be initialized at the time userSetup.py is being executed? If it is something that depends on Maya's UI being fully established, you could import it deferred:

cmds.evalDeferred("import riggingTools as rt")



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

Aren Voorhees

unread,
Nov 24, 2015, 5:06:25 PM11/24/15
to Python Programming for Autodesk Maya
It seems like that was it!  Once I changed to using cmds.evalDeferred() it worked. I did see error messages before setting that, but the way they were worded I thought they were regarding an issue with something else.  Thanks as always Justin.   


On Tuesday, November 24, 2015 at 3:14:13 PM UTC-6, Justin Israel wrote:
Are you sure that the import isn't failing, in your userSetup.py ? Does it depend on any facilities that may not yet be initialized at the time userSetup.py is being executed? If it is something that depends on Maya's UI being fully established, you could import it deferred:

cmds.evalDeferred("import riggingTools as rt")



On Wed, Nov 25, 2015 at 9:53 AM Aren Voorhees <are...@gmail.com> wrote:
Ok, an update!  

Once I started looking for my print statement in the output window as Robert suggested, I was able to work out a few issues to get things closer to working.  

So now things like
import pymel.core as pm
and 
import maya.cmds as cmds
are working, so that's progress at least!

But now, I'm trying to also make it import some of my own scripts automatically.  Something like:
import riggingTools as rt

When I run that from the script editor it works fine, but when I put that in in my userPrefs.py and run rt.someMethod() it says name 'rt' is not defined.  So for some reason it works when I import it in Maya, but does not work when I try to run it in in my userStartup.py  

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Nov 24, 2015, 5:48:52 PM11/24/15
to python_in...@googlegroups.com
On Wed, Nov 25, 2015 at 11:06 AM Aren Voorhees <are...@gmail.com> wrote:
It seems like that was it!  Once I changed to using cmds.evalDeferred() it worked. I did see error messages before setting that, but the way they were worded I thought they were regarding an issue with something else.  Thanks as always Justin.   

It was a shot in the dark! That's cool that it was actually the fix.
 


On Tuesday, November 24, 2015 at 3:14:13 PM UTC-6, Justin Israel wrote:
Are you sure that the import isn't failing, in your userSetup.py ? Does it depend on any facilities that may not yet be initialized at the time userSetup.py is being executed? If it is something that depends on Maya's UI being fully established, you could import it deferred:

cmds.evalDeferred("import riggingTools as rt")



On Wed, Nov 25, 2015 at 9:53 AM Aren Voorhees <are...@gmail.com> wrote:
Ok, an update!  

Once I started looking for my print statement in the output window as Robert suggested, I was able to work out a few issues to get things closer to working.  

So now things like
import pymel.core as pm
and 
import maya.cmds as cmds
are working, so that's progress at least!

But now, I'm trying to also make it import some of my own scripts automatically.  Something like:
import riggingTools as rt

When I run that from the script editor it works fine, but when I put that in in my userPrefs.py and run rt.someMethod() it says name 'rt' is not defined.  So for some reason it works when I import it in Maya, but does not work when I try to run it in in my userStartup.py  

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/e8f33ffd-af81-4f33-8172-6efdd18b17d6%40googlegroups.com.

Robert White

unread,
Nov 24, 2015, 6:22:18 PM11/24/15
to Python Programming for Autodesk Maya
You're right, it just has to be importable, so sys.path. I think I got my maya / python brains crossed there.

Also glad it got worked out!


On Tuesday, November 24, 2015 at 2:20:55 PM UTC-6, Justin Israel wrote:
On Wed, Nov 25, 2015 at 8:47 AM Robert White <robert....@gmail.com> wrote:
So I just tested that in Maya2016 and it seemed to work fine. Remember that anything printed in a userSetup.py will most likely end up in the output window (which is minimized by default in 2016), and not in the script editor window once Maya is done loading. This is because userSetup.py is run before the various GUI elements have actually been spun up and initialized.

Just in case, double check that the env variable MAYA_SKIP_USERSETUP_PY isn't set, and obviously that your userSetup.py is on the PYTHONPATH.

I didn't think it had to be on the PYTHONPATH if you use one of the standard Maya location. Doesn't it just need to live in a maya "scripts" directory? Either in the "shared/scripts" or "<version>/scripts" locations?



On Tuesday, November 24, 2015 at 1:15:19 PM UTC-6, Aren Voorhees wrote:
Hey everyone,

I'm trying to use the userSetup.py to do some imports whenever Maya is started up (ex. import pymel.core as pm, import maya.cmds as cmds, etc).  However I can't seem to get the file to run on Maya's startup.  I know I've done this before on a different computer without issue.  Even boiling it down to something as simple as putting: print "Hello World" in userSetup.py doesn't do anything.  

Inside of Maya I've tried doing: 

import sys


for p in sys.path:
   
print p


Of course that gives me a list of paths...I've tried putting the userSetup.py in many different of those places and still no luck.

I also tried:

print cmds.internalVar(usd=True)

and putting userSetup.py there (which I had already tried earlier, but hey, why not).

I've also tried blowing away my maya.env file to make sure that wasn't doing anything weird.  

Any ideas?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

nemcov...@gmail.com

unread,
Jan 30, 2018, 1:32:47 PM1/30/18
to Python Programming for Autodesk Maya
Hi! Aren, help me, trying to get into Maya fail UserSetap, but nothing happens. You can tell what to do, or throw off your file. Thank you

Justin Israel

unread,
Jan 30, 2018, 1:37:09 PM1/30/18
to python_in...@googlegroups.com


On Wed, Jan 31, 2018, 7:32 AM <nemcov...@gmail.com> wrote:
Hi! Aren, help me, trying to get into Maya fail UserSetap, but nothing happens. You can tell what to do, or throw off your file. Thank you

What do you currently have in your userSetup.py and where have you placed it? 

For Aren it was an issue with particular statements in the file not working. 
 


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4c25db4a-1f60-470e-84c5-5877c64a7b0a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages