HDA python module doesn't work every first time it is opened

   5406   6   1
User Avatar
Member
41 posts
Joined: 5月 2010
Offline
Hi!

I have a weird problem with Python and Digital Assets:
My HDA has a few Python modules which runs every time I press a certain button.
The problem is every time I start a new session I cannot use the button, It gives an error that the python module doesn't exist.
So I have to dive inside the python module, just add a single space to the code and remove it and save the changes to be able to use the tool. I feel it is because the python module does not reload automatically.
I have been dealing with this problem for quite a while and don't know how to solve it.
It would be great if you can help me with this issue.

Thanks
-Ali
User Avatar
Member
219 posts
Joined: 10月 2015
Offline
Hello,
If it's just a reload problem just use the “reload(yourModule)” function.
But, as that's the entire module which not found, I suggest you to add your module folder path in your system path :
import sys
currentPackagePath = "fullPathToYourScript/moduleFolder"
if not currentPackagePath in sys.path :
    sys.path.append(currentPackagePath)
#Now, import your module should work
import yourModule

Hope that help you.
User Avatar
Member
41 posts
Joined: 5月 2010
Offline
julca
Hello,
If it's just a reload problem just use the “reload(yourModule)” function.
But, as that's the entire module which not found, I suggest you to add your module folder path in your system path :
import sys
currentPackagePath = "fullPathToYourScript/moduleFolder"
if not currentPackagePath in sys.path :
    sys.path.append(currentPackagePath)
#Now, import your module should work
import yourModule

Hope that help you.


Thanks Julca
But the python module is a part of my digital asset, How about that?
User Avatar
Member
219 posts
Joined: 10月 2015
Offline
bigquix
But the python module is a part of my digital asset, How about that?
Isn't possible to add this sort of code once in the onCreated event of the hda ?
Sorry not to be more help. If you can isolate the problem in a simplified hda maybe I can help you better ?
User Avatar
Member
86 posts
Joined: 2月 2014
Offline
I have the exact same problem, very troublesome. Did you find a solution already?
User Avatar
Member
15 posts
Joined: 3月 2015
Offline
For anyone stumbling across this topic,

hou.hda docs [www.sidefx.com]

Running in the shell or in a callback:
hou.hda.reloadHDAModule(hou.node(pathtonodehere).hdaModule())
will reload your python houdini module imports

Hope it helps someone
Edited by Roger Wellard - 2020年9月1日 10:03:06
User Avatar
Member
1 posts
Joined: 11月 2013
Offline
Roger Wellard
Running in the shell or in a callback:
hou.hda.reloadHDAModule(hou.node(pathtonodehere).hdaModule())
will reload your python houdini module imports

Hope it helps someone

Thanks Roger Wellard! It did help me
  • Quick Links