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

Revision history [back]

click to hide/show revision 1
initial version

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

Hello all,

It is possible to load custom python packages in the 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 a few 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 the code in the measure

sys.path.insert(0, '/root/.pyenv/versions/3.12.3/lib/python3.12/site-packages')

where /root/.pyenv/versions/3.12.3/lib/python3.12/site-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 2.? 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!

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

Hello all,

It is possible to load custom python packages in the 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 a few 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 the code in the measure

sys.path.insert(0, '/root/.pyenv/versions/3.12.3/lib/python3.12/site-packages')

where /root/.pyenv/versions/3.12.3/lib/python3.12/site-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 2.? 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! you!

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

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 a few 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 codecode.
  2. Using the code in the measuremeasure like so,

sys.path.insert(0, '/root/.pyenv/versions/3.12.3/lib/python3.12/site-packages')

where /root/.pyenv/versions/3.12.3/lib/python3.12/site-packages

/root/.pyenv/versions/3.12.3/lib/python3.12/site-packages

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

Is there a better way then 2.? 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!

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

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, '/root/.pyenv/versions/3.12.3/lib/python3.12/site-packages')

where

/root/.pyenv/versions/3.12.3/lib/python3.12/site-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 2.? 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!

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

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, '/root/.pyenv/versions/3.12.3/lib/python3.12/site-packages')'path_to_custom_python_packages')

where

/root/.pyenv/versions/3.12.3/lib/python3.12/site-packages'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 2.? 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!

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

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!