Jump to content

Import Hou error


oldiesgoodies

Recommended Posts

Hi

I am trying to import hou externally. I have added Houdini python path then I issue "import hou" and that is what I get

adding the path

sys.path.append(os.environ['HFS'] + "/houdini/python%d.%dlibs" % sys.version_info[:2])

and the error

16 """

17

--> 18 import _hou

19 import new

20 new_instancemethod = new.instancemethod

importError: DLL load failed: %1 is not a valid Win32 application.

I am under Windows7 64

Any ideas?

thanks

Link to comment
Share on other sites

  • 4 years later...
  • 1 year later...

Hey guys,

I know this is a stale thread, but just in case anybody stumbles on this thread trying to get it working... I wanted to say I have an external IDE (WingIDE) able to run with the python install that comes with houdini and I can import hou.  I have used an external IDE with hython on a mac for a few years (since circa 2009 I think) and it worked pretty well.  On the mac side, if my memory serves me, it didn't take much more than pointing my ide at hython in the $HFS/bin directory and setting the python path to include the $HFS/houdini/python2.7libs folder.  

I recently switched all my setup over to windows.  On the windows side I encountered the same error that people have been reporting (error trying to "import _hou"), but after some tinkering today and I have it mostly working all though it throws some warnings about 4 bindings it couldn't do.... but those warnings don't seem to be affecting any of the scripts I tried.  I thought I would share just in case someone is trying to figure it all out like I just was.

I am now on Windows 10, with Houdini 15.5 and python 2.7.

This old help doc was helpful: http://www.sidefx.com/docs/houdini13.0/hom/commandline#idm47503603268592

Here is what I did:

In windows environment User variables in under the windows Control Panel/System/Advanced Settings/Environment Variables (just look up "Setting Windows Environment Variables" to get step by step:
Create and/or Set "HFS" correctly (to houdini version folder in Program Files)
Add "%HFS%/bin;" to Path (this is what the old houdini doc mentioned about windows and was the missing piece for me)

Point in your IDE to:
python executable - c:\Program Files\Side Effects Software\Houdini 15.5.673\python27\python2.7.exe
add to python path - c:\Program Files\Side Effects Software\Houdini 15.5.673\houdini\python2.7libs

Bonus to make a cmd shell work too, in windows environment User variables:
Add %HFS%/python27 to Path
Add PYTHONPATH with %HFS%\houdini\python2.7libs

I provided an image of the final version of my environment variables and a shot of code running in WingIDE and the resulting file open in houdini.

Hope this helps someone!

-bk

systemvars.jpg

importhou.jpg

Edited by briankulig
some formatting
  • Thanks 2
Link to comment
Share on other sites

  • 11 months later...

Hello brainkulig, the steps above work on houdini 16.5 and PyCharm 2017.3.

Would you happen to know how to connect to a live instance of Houdini? similar to what you can do with Mayacharm (where i can execute/code in my IDE an seeing results in Houdini itself?)

 

Thanks

-stas

Edited by stascrash
Link to comment
Share on other sites

Hey Stascrash,

Glad it worked out for you!   I am versioned up to Houdini 16.5 as well and it works in there.

As for your pycharm question, there isn't something doing that I can find, but its pretty easy to setup with ports if you are comfortable with python.  When you do an "import hou" you are actually creating a running instance of houdini, but no interface.  I don't know if there is a way to show it.  But if you want two active programs (IDE and Houdini) to talk to each other, ports are the way to go.  I have done it in the past with Maya and Max.  I looked at Mayacharm, and that is what it appears to be doing too.  

Here is a tutorial of the basic idea:

https://pythontips.com/2013/08/06/python-socket-network-programming/

A couple of tips I remember off the top of my head are that using the port to trigger the app to just execute a python file is easier and safer than trying to send the python code through the port.   And server and/or client has to continue running depending on how you set it up.  I seem to remember that houdini (and I think maya too) will often close the python thread once it executes whatever code it does.  There is a way around by running a background thread (which also prevents the program from hanging waiting for input from the socket) that is buried in the docs somewhere, but I don't remember where off hand.

Good luck!

-bk

 

Edited by briankulig
Link to comment
Share on other sites

  • 7 months later...

Hey Kris,

Assuming the "it" in your question is getting your ide running houdini's python - I had it running on a mac for several years before i unfortunately had to migrate to windows.  It was actually much simpler on the mac side.  If i remember right, I just pointed my python ide project's python executable to be the "hython" in the bin folder of the houdini install and it got the correct libs automatically.  Unfortunately I don't have a mac these days to test if that is still the case.

-bk

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...