Jump to content
catchyid

Is it possible to import hou module outside houdini?

Recommended Posts

Hi,

If I try to import "hou" module using the standard python2.7 interpreter, it crashes. 

If I use the python interpreter that's shipped with Houdini and I import "hou" module, it also complains about jemalloc libs

I see that the only way to use "hou" module is either (1) inside houdini directly (e.g. in parameters), OR (2) by running hython --> Is this correct?

I just don't see it logical that I have a python module "hou" that can only be used inside hython interpreter? for example, If I were to write a studio wide tool that needs to process houdini object, then in this specific case I must hython, otherwise I can use python? 

Thanks

 

Share this post


Link to post
Share on other sites

Hi,

Just an update if someone is still reading :) It seems to me that application specific interpreters, such as hython in Houdini or mayapy for Maya, are just there to run their own python modules...I "think" over simplifying hou as just a standard python module is just wrong, i.e. it must be run by hython interpreter ... Now that seems rather limiting! what if you want to have a python script that processes both houdini and maya objects? It would be still possible, but this won't be in "one" application.

Share this post


Link to post
Share on other sites

It is possible(or at least was possible) to use the hou module in a standard system interpreter, there's even a help page somewhere in the docs. Using both Maya and Houdini interpreters within a single app (or package) could be tricky, but definitely possible and depends on your use case. Unless you required to use both APIs at the same time you can organize your code in such a way where Maya mypy instance communicates with a standalone Hython instance through a simple intermediate disk file or an RPC server.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Alex...Logically, it should be possible to use them in standard interpreter as you mentioned, maybe I am doing something wrong (my first time to write python code ;) ) ...

Share this post


Link to post
Share on other sites

Guys, I am not a developper by any means, but from what I understand, and "API" is an Application Programming Interface, which means it requires an instance of your application to be run in any case (Houdini, Maya...). The module you use "HOU" is just a library of functions that Python (or C++ in case of SDK) understands and calls the application (Houdini, Maya...). So it is really just an "interface" between standard programming language and an application.

I guess you can run an instance of your application in "command line" (Houdini or Maya with no GUI) and use that / declare it from a standard Python file executed in Python, and from there it should work.

But to don't ask my how, never tried with Houdini or Maya.

Share this post


Link to post
Share on other sites

Yes, what you says is correct JO. The problem I am facing is compatibility between binaries, meaning, we have  main components:

(1) the default python interpreter,

(2) python interpreter/libs that ships with Houdini (are they exactly the same like the default implementation, i.e. item 1, or do they have something special, I guess only SideFX people will know) 

(3) Hou python module

Now, a simple question: can I import (3) using (1) OR I "must" use (2) in order to import (3)? In theory, I should be able to use the default interpreter, ie (1), to import Hou but from my testing this is not the case. There are many reasons why for this limitation (for example, binaries complied with different flags, mismatched versions, it's too complicated...). Anyhow, my conclusion is that I must use (2) to import Hou. 

Now, add this compatibility issue using Maya modules, Maya Python interpreter...

 

Share this post


Link to post
Share on other sites

just an update : It's possible to import hou in standard python interpreter...the problem I was having is the python interpreter I used was compiled with gcc 5.4 and Houdini was compiled with gcc 6.3 --> so it's a binary (or ABI) incompatibility, hence the crash. To fix there are two solutions: either use the python interpreter shipped with Houdini, or update the python interpreter to match at least the same gcc version used to compile Houdini...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×