Archived post by Antidistinctlyminty

@mestela You can get hou in a regular Python shell

On windows you have to set the `HFS` environment variable

I have a script that I run via an `import`

“`python ”’Set up the environment so that “import hou” works.”’ import sys, os
# Importing hou will load in Houdini’s libraries and initialize Houdini. # In turn, Houdini will load any HDK extensions written in C++. These # extensions need to link against Houdini’s libraries, so we need to # make sure that the symbols from Houdini’s libraries are visible to # other libraries that Houdini loads. So, we adjust Python’s dlopen # flags before importing hou.
# This needs to be set previous to calling the script hfs = os.environ[‘hfs’]
if hasattr(sys, “setdlopenflags”): old_dlopen_flags = sys.getdlopenflags() import DLFCN sys.setdlopenflags(old_dlopen_flags | DLFCN.RTLD_GLOBAL)
try: import hou except ImportError: # Add $HFS/houdini/python2.7libs to sys.path so Python can find the # hou module. os.environ[‘path’] = ‘{};{}\bin’.format(os.environ[‘path’], hfs) sys.path.append(os.path.join(hfs, ‘houdini’, ‘python2.7libs’)) import hou finally: if hasattr(sys, “setdlopenflags”): sys.setdlopenflags(old_dlopen_flags)“`