Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

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

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

antonszilasi's avatar

updated 2025-11-18 09:26:19 -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

1 Answer

Sort by ยป oldest newest most voted
0

answered 2025-11-20 13:50:59 -0600

antonszilasi's avatar

updated 2025-11-20 13:51:24 -0600

After a fair bit of research, I determined the the only other alternatives to either setting the python path like so:

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

OR adding this in hte measure

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

Is to

  1. Recompile OpenStudio to include the libraries which are needed
  2. Copy the packages over to the OpenStudio installation directory

If I attempt either of this I will add updates to this question

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Question Tools

1 follower

Stats

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

Seen: 105 times

Last updated: Nov 20