Importing external Python modules into Houdini

   13259   7   3
User Avatar
Member
49 posts
Joined: 9月 2013
Offline
Hello everyone, I am trying to import the googlemaps module into Houdini, but having no luck so far.

Has anyone ever tried to import external Python Modules into Houdini, any sort of help would be great.

Thanks a lot!
User Avatar
Member
2551 posts
Joined: 6月 2008
Offline
If you are getting unknown module errors or some thing similar to that on import it may be something as simple as a pathing error.

You can manually add a specific path to your system at runtime before you attempt to import any module by using the sys.path.append feature of python. Check out the docs on this.

EXAMPLE:

sys.path.append(“./lib”)
import pyluxcore
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
637 posts
Joined: 6月 2006
Offline
made a simple example where you can insert the python modules in the houdini user profile folder: https://youtu.be/xoVORgBT190 [youtu.be]
User Avatar
Member
49 posts
Joined: 9月 2013
Offline
Thanks a lot for the reply guys, but the problem does not seem to be iim importing the module “googlemaps”, the problem is that the class “GoogleMaps” in the module “googlemaps” is not callable

So when I say:

>> import googlemaps

it imports the module, since there is no traceback error for that statement

but when i do the following:

>> from googlemaps import GoogleMaps

it gives an error:

Traceback (most recent call last):
File “<console>”, line 1, in <module>
ImportError: cannot import name GoogleMaps


Do you guys know what could be the reason for this??

Thanks again!
User Avatar
Member
2551 posts
Joined: 6月 2008
Offline
Try:


print dir(googlemaps)

That should give you a list of all possible callable functions within the module. Perhaps GoogleMaps is not the correct spelling…?
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
99 posts
Joined: 8月 2014
Offline
This will come in handy. Seems far simpler than maya.
User Avatar
Member
22 posts
Joined: 6月 2006
Offline
I'm appending the path where the python module lives via houdini15.0/scripts/python/pythonrc.py

import sys
sys.path.append('…./path')


This works well for me importing external modules into any houdini context , included HDA.

The problem I'm having is that when I update the external module, I have to re-start Houdini to have the HDA pick up the changes.

Is there any way to re-source an external Python module from within an HDA
?
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
User Avatar
Member
101 posts
Joined: 2月 2015
Offline
mrWolf
Is there any way to re-source an external Python module from within an HDA
?
Hi, I think the python “reload” function is what you need :

import myModule
reload(myModule)
https://vimeo.com/user43710534 [vimeo.com]
  • Quick Links