Maya script won't run in Maya 2022. `reload` is not defined

3k views Asked by At

Trying to run a script that works fine in maya 2018 but wont in 2022

import gw_anim_clip
reload(gw_anim_clip)
gw_anim_clip.anim_clip_ui()

I'm getting this error:

Error: name 'reload' is not defined
Traceback (most recent call last):
  File "<maya console>", line 2, in <module>
NameError: name 'reload' is not defined # 
2

There are 2 answers

0
Achayan On

reload is not available in python 3.9 and maya 2022 already in 3.9. So you have to use importlib.reload to reload a module.

import importlib
import gw_anim_clip
importlib.reload(gw_anim_clip)
gw_anim_clip.anim_clip_ui()
0
Ilia Sobert On

Maya 2022 use python 3.7 and you need to import reload first.

from imp import reload
import gw_anim_clip
reload(gw_anim_clip)
gw_anim_clip.anim_clip_ui()