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

How to add pip packages/Ruby gems to a OpenStudio workflow (.osw)

asked 2025-11-13 18:55:48 -0600

antonszilasi's avatar

updated 2025-11-14 17:29:58 -0600

Hello unmet hours community,

I am in the process of writing some python measures which are intended to work in a OpenStudio workflow (.osw), I came across this measure from PNNL

the measure uses the pip package copper by importing it in measure.rb like so:

import copper as cp 
import typing

However by default the Openstudio cli the command

openstudio run --workflow

does not come with this pip package preloaded, so how can I load pip packages/ or Ruby gems into the OpenStudio cli?

Thank you!

---- EDIT and Solution

After digging deeper, just passing --python_path to the site_packages directory where a pip package is contained worked for me

For example this command -

openstudio --python_path ~/.pyenv/versions/3.12.3/lib/python3.12/site-packages run --workflow /mnt/c/openstudio-building-energy-standard-measures-gem/simple-python-measure.osw

edit retag flag offensive close merge delete

Comments

1

@antonszilasi have you tried passing --python_home instead?

Jeremy's avatar Jeremy  ( 2025-11-14 12:28:39 -0600 )edit
1

Hi Jeremy, yup just dug deeper and yes I got just passing python path to work thank you!

antonszilasi's avatar antonszilasi  ( 2025-11-14 12:31:58 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2025-11-14 01:15:27 -0600

updated 2025-11-14 01:20:19 -0600

It's a Python measure, so you need to use the --python_path and --python_home options of the CLI. For instance, I'm running OpenStudio 3.10 which uses Python 3.12. I installed Python 3.12 on my machine (I'm using pyenv), installed the copper library (pip install copper-bem), ran the following command, and the measure ran successfully.

openstudio --python_path /Users/lero023/.pyenv/versions/3.12.10/ --python_home /Users/lero023/.pyenv/versions/3.12.10 run --workflow wkfl.osw

Here's the content of the OSW file:

{
"seed_file": "model.osm",
"weather_file": "USA_CO_Golden-NREL.724666_TMY3.epw",
"steps": [
    {
        "measure_dir_name": "GenerateIPLVChillerElectricEIRPerformanceCurves",
        "arguments": {
        "chiller_name": "TestChiller",
        "chiller_compressor_type": "centrifugal",
        "chiller_speed_control": "constant",
        "chiller_condenser_type": "water",
        "chiller_capacity_unit": "ton",
        "chiller_capacity": 150,
        "chiller_efficiency_unit": "kW/ton",
        "chiller_full_load_efficiency": 0.6,
        "chiller_part_load_efficiency": 0.5
        }
    }
]

}

The model.osm contains a Chiller:Electric:EIR object.

edit flag offensive delete link more

Comments

1

(I don't think you should be passing both python_path and python_home)

Julien Marrec's avatar Julien Marrec  ( 2025-11-14 10:35:33 -0600 )edit
1

as @Julien Marrec noted, openstudio --python_home /Users/lero023/.pyenv/versions/3.12.10 run --workflow wkfl.osw works for me, I don't need to (shouldn't?) pass --python_path. I did have to use the same version of Python as OpenStudio. Is your version the same?

Jeremy's avatar Jeremy  ( 2025-11-14 12:20:57 -0600 )edit
1

answered 2025-11-14 01:12:16 -0600

Jackson's avatar

Hi Antonszilasi, glad to see you try so interesting things.

For your question, i think the part Loading Custom Gems in OpenStudio Command Line Interface can help. It introduces how to load Ruby gems through Openstudio CLI in detail. Pls find your solution in it.

Good luck!

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-13 18:55:48 -0600

Seen: 92 times

Last updated: Nov 14