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

Error in Running EnergyPlus in Python using API

asked 2020-10-11 17:21:26 -0500

sajithwjay gravatar image

updated 2021-01-04 05:51:03 -0500

I am using the syntax below to run EnergyPlus from python using the EnergyPlus API. It gives me an error---> TypeError: run_energyplus() missing 1 required positional argument: 'command_line_args'.

If you could guide me as to what may be missing, Id be grateful.

import sys
sys.path.insert(0, 'C:\EnergyPlusV9-4-0') 

from pyenergyplus.api import EnergyPlusAPI

api = EnergyPlusAPI()

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-10-12 07:43:22 -0500

updated 2020-10-12 07:44:43 -0500

You need to pass the state manager

import sys
from pyenergyplus.api import EnergyPlusAPI

def dummy_callback_function(state_argument):
    print("My argument is called state_argument to avoid duplicating the outer variable below called state")

api = EnergyPlusAPI()
state = api.state_manager.new_state()
api.runtime.callback_begin_new_environment(state, dummy_callback_function)
        '-w', 'C:/EnergyPlusV9-4-0/WeatherData/USA_IL_Chicago-OHare.Intl.AP.725300_TMY3.epw',
# If you need to call run_energyplus again, then reset the state first
edit flag offensive delete link more



Hi Julien, I have tried it and it works. Thank you for the pointers. I have a similar concern related to running energyplus as a PlugIn using Python. I will post it in another question. Regards.

sajithwjay gravatar image sajithwjay  ( 2020-10-12 15:42:22 -0500 )edit

Your Answer

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

Add Answer


Question Tools



Asked: 2020-10-11 17:21:26 -0500

Seen: 172 times

Last updated: Jan 04