I’ve been spending some time in Houdini recently, so thought I’d share how to setup your python environment for best results when working with your own scripts and sharing them with others.
Getting Environment Variables and Folder Locations
You might have noticed that a lot of file paths in Houdini look something like:
This is because Houdini is getting locations from your environment variables, so that it can point to everyone’s home folder regardless of where that may be.
To view these we can open a textport window and use the echo command.
For example, the text below will print your user directory.
If you see a variable like this that you don’t recognize, try using echo to find out what it is!
Editing Environment Variables
You can edit environment variables for Houdini by changing the .env file found in your Houdini 16.0 folder. To get this folder type in the textport:
In this file you can define whatever variables you might like. A list of environment variables can be found in the official documentation.
As an example, here I’ve set my python version to use 2.7.
Where do Python Scripts Live?
To import your own python scripts into Houdini’s python editor, the scripts must be stored in the home directory. Navigate to the home directory and create a folder called “Python 2.7 Libs” (or whatever is appropriate to your python version). You’ll need to open Houdini again every time you make a change to this folder, but if you restart you should now be able to import your own scripts!
Editing Environment Variables for Multiple Users
This is all great, but what about multiple users working with version control? How do we share scripts and digital assets between users?
The best way to do this is to set the $HSITE variable in windows. This points to a home directory that contains a “Houdini 16.0” (or other version) folder. This folder can be versioned and contains your python library, digital assets and environment variables. With HSITE set and the folder kept up to date, these settings can be shared between users.
To do this, go to System in your control panel, open “Advanced System Settings” and click the Environment Variables button.
With this open, click new and enter “HSITE” as your variable name and the directory containing the “Houdini 16.0” folder as the value.
Houdini will now take all scripts, assets and variables from this location!