Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Could not find ExpandObjects executable: #8433

Closed
chelydrae opened this issue Dec 19, 2020 · 5 comments
Closed

ERROR: Could not find ExpandObjects executable: #8433

chelydrae opened this issue Dec 19, 2020 · 5 comments
Assignees

Comments

@chelydrae
Copy link

Issue overview

Dear all,
Im trying to run the following script in Python:


import sys
sys.path.insert(0, '/Applications/EnergyPlus-9-4-0')
from pyenergyplus.api import EnergyPlusAPI

file = ['-w', 'weather.epw', '-d', 'out/', '-r', '-x', 'kursat.idf']
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)
api.runtime.run_energyplus(state,file)
api.state_manager.reset_state(state)
api.runtime.callback_begin_new_environment(state, dummy_callback_function)
api.runtime.run_energyplus(state,file)

All tutorials went well so far and the pyenergyplus module can be found. But when executing

`api.runtime.run_energyplus(state,file)
`

python throws an error saying that:

ERROR: Could not find ExpandObjects executable: /Users/muellerp/opt/anaconda3/envs/barbarossa/bin/ExpandObjects.

I looked up in the source code of Energyplus and found out that the function _NSGetExecutablePath is used to get the executable path which is a MacOS-specific function. It seems that the executable path of the Energyplus modules is overwritten by the python executable path as the outputted path in the error message changes when the Python executable is changed (e.g. from Python 3.9 to Python 3.6).

For now I solved this by moving the whole installation folder to the path of the python executable to make it work but this is not a clean solution.
Do you have an idea what the problem might be? Is this a potential bug in the source code?

Details

  • Platform MacOs Catalina
  • Version of EnergyPlus: 9.4.0

Best regards,
Chelydrae

@Myoldmopar
Copy link
Member

I'm so glad you are experimenting with the new API! Looks like you have a great start.

As you suspected, this is a known limitation where the executable is assumed to be the EnergyPlus install directory, but it resolves to the Python executable.

Easy workaround though, don't rely on EnergyPlus to call ExpandObjects. Just run ExpandObjects ahead of the call to run EnergyPlus. Here's a basic script for it, just know that ExpandObjects expects to find an in.idf file and produces an expanded.idf file:

import shutil
import subprocess

shutil.copyfile('kursat.idf', 'in.idf')  # copy the file to in.idf for ExpandObjects
try:
    subprocess.check_call('/Applications/EnergyPlus-9-4-0/ExpandObjects')
except subprocess.CalledProcessError:
    ...  # handle the error
...  # check the expanded.idf exists and is valid
shutil.copyfile('expanded.idf', 'kursat_expanded.idf')

Then when you call run_energyplus(...), just use the expanded file name.

I will leave this issue open because we should be able to detect the proper directory for EnergyPlus binaries relative to the library.

PS: If you end up having the same issue with ReadVars, you could also do the same workaround by executing ReadVars manually from Python. I'm not suggesting this is a permanent solution, but it could get you going right away I think!

@mitchute
Copy link
Collaborator

mitchute commented Jun 1, 2021

@jmarrec can you confirm that #8574 addresses this?

@jmarrec
Copy link
Contributor

jmarrec commented Jun 2, 2021

@mitchute that's a typo, I meant #8483 - pyenergyplus: system exit called when energyplus can't run

@JasonGlazer
Copy link
Contributor

It would be good if when the API is called that you can tell it where the utility programs will be located. Maybe define a new API function that takes a path to them?

In addition, if the suggested path is not set or does not contain the utility programs, it would be good if EnergyPlus generated a more understandable error message than "ERROR: Could not find ExpandObjects executable: /Users//ExpandObjects." that would direct users to set the path correctly.

@Myoldmopar
Copy link
Member

This was completed in #8918

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants