How can I load custom python packages (pip) without extra OSW arguments

asked 2025-11-14 17:36:12 -0600

antonszilasi's avatar

updated 2025-11-14 17:41:30 -0600

Hello all,

It is possible to load custom python packages into a openstudio workflow by calling openstudio like so:

openstudio --python_path /path_to_python_packages run --workflow wkfl.osw

However I'd like to do this without adding the --python_path argument, I've tried two things

  1. Setting the PYTHONPATH environment variable, this doesn't work for a OpenStudio workflow I believe its something to do with the OpenStudio source code.
  2. Using code in the measure like so,

sys.path.insert(0, 'path_to_custom_python_packages')

where

'path_to_custom_python_packages

is the path to the custom python packages which we want to use in the measure. This does work and I'm inclined to use something like this as a solution

Is there a better way then the above? Or perhaps I'm missing something here?

I'd also like to ask what is the correct way to load custom python modules into a python measure on the OpenStudio server.

Thank you!

edit retag flag offensive close merge delete