Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Maya 2024, can't reload python module

Maya 2024, can't reload python module

adityakumar7024
Explorer Explorer
781 Views
2 Replies
Message 1 of 3

Maya 2024, can't reload python module

adityakumar7024
Explorer
Explorer

I am currently working on a python script and every time I make changes in the script, I need to re-open maya to run the updated module.

 

The reload function does not seems to be working.

I tried all 3 versions of python reloading command. Though it doesn't return any error while running the reload command, it also doesn't reload the module and runs the older version of code when I try to run the module :

 

I tried : 

reload(moduleName)

import imp
imp.reload(moduleName)


import importlib
importlib.reload(moduleName)

Any idea why this could be happening?

 

 

0 Likes
Accepted solutions (1)
782 Views
2 Replies
Replies (2)
Message 2 of 3

lee.dunham
Collaborator
Collaborator

If `moduleName` if the name of the module then you're not reloading correctly.

Reload in python (all versions) needs the module object.

There are other ways but more context would definitely help.

0 Likes
Message 3 of 3

adityakumar7024
Explorer
Explorer
Accepted solution
Thanks for your reply.
I figured out what my mistake was. I was reloading the root directory and thought it would also reload the modules underneath that directory. Instead, I had to reload that particular module from the directory.
'import' loads every modules from the Dir, while reload command only works on any one particular module.

0 Likes