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

Revision history [back]

So in answer to my own question, the issue was trying to build using Visual Studio 2015. After a few missteps I've managed to get a working build using Visual Studio 2013. Thanks definitely due to @MarkAdams!

There are five main steps to the process - setting up the tools required, cloning the source code, configuring and generating the solution file in CMake, building in Visual Studio 2013, and finally setting up your Python environment

1) Set up the build environment for Windows

Install the software listed:

Add C:\Qt\Qt5.3.2\5.3\msvc2013_64_opengl\bin to the System Path

2) Clone OpenStudio from Github

Launch Git Bash and run the following commands in the folder you want to build in. I ran directly in C: so my source folder will be C:\OpenStudio throughout this step-by-step.

git clone -b develop git@github.com:NREL/OpenStudio.git
cd OpenStudio
mkdir build

3) Configure and generate in CMake

  • Launch CMake

  • Set the path to the source code: C:\OpenStudio and the build path: C:\OpenStudio\build

  • Hit Configure and selected Visual Studio 12 2015 Win64 from the dropdown

  • Leave the radio button on the default, Use default native compilers

  • CMake runs for a little while then will hit an error which prompts to set SWIG_EXECUTABLE

  • Set the full path to the swig.exe executable C:/swigwin-3.0.7/swig.exe

  • Tick BUILD_PACKAGE and BUILD_PYTHON_BINDINGS

  • Hit Configure

  • Hit Configure again (not sure if this was needed but it gets rid of the red highlighting on the new entries)

  • Hit Generate

4) Build in Visual Studio 2013

  • Open up Visual Studio 2013 and open the OpenStudio.sln file from the build directory

  • Build > Configuration Manager set the build configuration to Release. This is needed because we don't have python_d.lib on the system which is required for a Debug build

  • Set to build PACKAGE since that setting wasn't set and this answer suggested we need it

  • Run Build > Build solution which churns away for a few hours and eventually spits out the final product

5) Add library path to PYTHONPATH

  • Add C:\OpenStudio\build\_CPack_Packages\win64\NSIS\OpenStudio-1.8.5.ffdfae3164-Win64\Python\openstudio to your environment

  • Test it out. Open up a Python shell and try import openstudioenergyplus

That's it. I get no error importing a module from the Python shell. That's really not as many steps as it felt like at the time! I hope this step-by-step helps someone out.

So in answer to my own question, the issue was trying to build using Visual Studio 2015. After a few missteps I've managed to get a working build using Visual Studio 2013. Thanks definitely due to @MarkAdams!

There are five main steps to the process - setting up the tools required, cloning the source code, configuring and generating the solution file in CMake, building in Visual Studio 2013, and finally setting up your Python environment

1) Set up the build environment for Windows

Install the software listed:

Add C:\Qt\Qt5.3.2\5.3\msvc2013_64_opengl\bin to the System Path

2) Clone OpenStudio from Github

Launch Git Bash and run the following commands in the folder you want to build in. I ran directly in C: so my source folder will be C:\OpenStudio throughout this step-by-step.

git clone -b develop git@github.com:NREL/OpenStudio.git
cd OpenStudio
mkdir build

3) Configure and generate in CMake

  • Launch CMake

  • Set the path to the source code: C:\OpenStudio and the build path: C:\OpenStudio\build

  • Hit Configure and selected Visual Studio 12 2015 Win64 from the dropdown

  • Leave the radio button on the default, Use default native compilers

  • CMake runs for a little while then will hit an error which prompts to set SWIG_EXECUTABLE

  • Set the full path to the swig.exe executable C:/swigwin-3.0.7/swig.exe

  • Tick BUILD_PACKAGE and BUILD_PYTHON_BINDINGS

  • Hit Configure

  • Hit Configure again (not sure if this was needed but it gets rid of the red highlighting on the new entries)

  • Hit Generate

4) Build in Visual Studio 2013

  • Open up Visual Studio 2013 and open the OpenStudio.sln file from the build directory

  • Build > Configuration Manager set the build configuration to Release. This is needed because we don't have python_d.lib on the system which is required for a Debug build

  • Set to build PACKAGE since that setting wasn't set and this answer suggested we need it

  • Run Build > Build solution which churns away for a few hours and eventually spits out the final product

5) Add library path to PYTHONPATH

  • Add C:\OpenStudio\build\_CPack_Packages\win64\NSIS\OpenStudio-1.8.5.ffdfae3164-Win64\Python\openstudio to your environment

  • Test it out. Open up a Python shell and try import openstudioenergyplus

That's it. I get no error importing a module from the Python shell. That's really not as many steps as it felt like at the time! I hope this step-by-step helps someone out.

So in answer to my own question, the issue was trying to build using Visual Studio 2015. After a few missteps I've managed to get a working build using Visual Studio 2013. Thanks definitely due to @MarkAdams!

There are five main steps to the process - setting up the tools required, cloning the source code, configuring and generating the solution file in CMake, building in Visual Studio 2013, and finally setting up your Python environment

1) Set up the build environment for Windows

Install the software listed:

Add C:\Qt\Qt5.3.2\5.3\msvc2013_64_opengl\bin to the System Path

2) Clone OpenStudio from Github

Launch Git Bash and run the following commands in the folder you want to build in. I ran directly in C: so my source folder will be C:\OpenStudio throughout this step-by-step.

git clone -b develop git@github.com:NREL/OpenStudio.git
cd OpenStudio
mkdir build

3) Configure and generate in CMake

  • Launch CMake

  • Set the path to the source code: C:\OpenStudio and the build path: C:\OpenStudio\build

  • Hit Configure and selected Visual Studio 12 2015 Win64 from the dropdown

  • Leave the radio button on the default, Use default native compilers

  • CMake runs for a little while then will hit an error which prompts to set SWIG_EXECUTABLE

  • Set the full path to the swig.exe executable C:/swigwin-3.0.7/swig.exe

  • Tick BUILD_PACKAGE and BUILD_PYTHON_BINDINGS

  • Hit Configure

  • Hit Configure again (not sure if this was needed but it gets rid of the red highlighting on the new entries)

  • Hit Generate

4) Build in Visual Studio 2013

  • Open up Visual Studio 2013 and open the OpenStudio.sln file from the build directory

  • Build > Configuration Manager set the build configuration to Release. This is needed because we don't have python_d.lib on the system which is required for a Debug build

  • Set to build PACKAGE since that setting wasn't set and this answer suggested we need it

  • Run Build > Build solution which churns away for a few hours and eventually spits out the final product

5) Add library path to PYTHONPATH

  • Add C:\OpenStudio\build\_CPack_Packages\win64\NSIS\OpenStudio-1.8.5.ffdfae3164-Win64\Python\openstudio to your environmentenvironment (not sure if it will always be called this, but something similar at least)

  • Test it out. Open up a Python shell and try import openstudioenergyplus

That's it. I get no error importing a module from the Python shell. That's really not as many steps as it felt like at the time! I hope this step-by-step helps someone out.

So in answer to my own question, the issue was trying to build using Visual Studio 2015. After a few missteps I've managed to get a working build using Visual Studio 2013. Thanks definitely due to @MarkAdams!

There are five main steps to the process - setting up the tools required, cloning the source code, configuring and generating the solution file in CMake, building in Visual Studio 2013, and finally setting up your Python environment

1) Set up the build environment for Windows

Install the software listed:

Add C:\Qt\Qt5.3.2\5.3\msvc2013_64_opengl\bin to the System Path

2) Clone OpenStudio from Github

Launch Git Bash and run the following commands in the folder you want to build in. I ran directly in C: so my source folder will be C:\OpenStudio throughout this step-by-step.

git clone -b develop git@github.com:NREL/OpenStudio.git
cd OpenStudio
mkdir build

3) Configure and generate in CMake

  • Launch CMake

  • Set the path to the source code: C:\OpenStudio and the build path: C:\OpenStudio\build

  • Hit Configure and selected Visual Studio 12 2015 Win64 from the dropdown

  • Leave the radio button on the default, Use default native compilers

  • CMake runs for a little while then will hit an error which prompts to set SWIG_EXECUTABLE

  • Set the full path to the swig.exe executable C:/swigwin-3.0.7/swig.exe

  • Tick BUILD_PACKAGE and BUILD_PYTHON_BINDINGS

  • Hit Keep hitting Configure

  • Hit Configure again (not sure if this was needed but it gets rid of until the red highlighting on the new entries)entries is all gone

  • Hit Generate

4) Build in Visual Studio 2013

  • Open up Visual Studio 2013 and open the OpenStudio.sln file from the build directory

  • Build > Configuration Manager set the build configuration to Release. This is needed because we don't have python_d.lib on the system which is required for a Debug build

  • Set to build PACKAGE since that setting wasn't set and this answer suggested we need it

  • Run Build > Build solution which churns away for a few hours and eventually spits out the final product

5) Add library path to PYTHONPATH

  • Add C:\OpenStudio\build\_CPack_Packages\win64\NSIS\OpenStudio-1.8.5.ffdfae3164-Win64\Python\openstudio to your environment (not sure if it will always be called this, but something similar at least)

  • Test it out. Open up a Python shell and try import openstudioenergyplus

That's it. I get no error importing a module from the Python shell. That's really not as many steps as it felt like at the time! I hope this step-by-step helps someone out.

So in answer to my own question, the issue was trying to build using Visual Studio 2015. After a few missteps I've managed to get a working build using Visual Studio 2013. Thanks definitely due to @MarkAdams!

There are five main steps to the process - setting up the tools required, cloning the source code, configuring and generating the solution file in CMake, building in Visual Studio 2013, and finally setting up your Python environment

1) Set up the build environment for Windows

Install the software listed:

Add C:\Qt\Qt5.3.2\5.3\msvc2013_64_opengl\bin to the System Path

2) Clone OpenStudio from Github

Launch Git Bash and run the following commands in the folder you want to build in. I ran directly in C: so my source folder will be C:\OpenStudio throughout this step-by-step.

git clone -b develop git@github.com:NREL/OpenStudio.git
cd OpenStudio
mkdir build

3) Configure and generate in CMake

  • Launch CMake

  • Set the path to the source code: C:\OpenStudio and the build path: C:\OpenStudio\build

  • Hit Configure and selected Visual Studio 12 2015 Win64 from the dropdown

  • Leave the radio button on the default, Use default native compilers

  • CMake runs for a little while then will hit an error which prompts to set SWIG_EXECUTABLE

  • Set the full path to the swig.exe executable C:/swigwin-3.0.7/swig.exe

  • Tick BUILD_PACKAGE and BUILD_PYTHON_BINDINGS

  • Keep hitting Configure until the red highlighting on the new entries is all gone

  • Hit Generate

4) Build in Visual Studio 2013

  • Open up Visual Studio 2013 and open the OpenStudio.sln file from the build directory

  • Build > Configuration Manager set the build configuration to Release. This is needed because we don't have python_d.lib on the system which is required for a Debug build

  • Set to build PACKAGE since that setting wasn't set and this answer suggested we need it

  • Run Build > Build solution which churns away for a few hours and eventually spits out the final product

  • Run the installer from C:\OpenStudio\build\_CPack_Packages\win64\NSIS

5) Make it visible to Python (edited)

  • Add library path to PYTHONPATH
      an __init__.py file to C:\Program Files\OpenStudio 1.8.5\Python\openstudio to make it into a Python package
    • Add C:\OpenStudio\build\_CPack_Packages\win64\NSIS\OpenStudio-1.8.5.ffdfae3164-Win64\Python\openstudio to your environment (not sure if the following to the __init__.py file for all the imports. My one's here. I think it will always could be called this, but something similar at least)

    • better structured (@MarkAdams, any suggestions? I notice you do from openstudioutilitiescore import * here

      import openstudioairflow as airflow
      import openstudioanalysis as analysis
      ...
      
    • Add C:\Program Files\OpenStudio 1.8.5\Python (or wherever you installed to) to you Python path

    • Test it out. Open up a Python shell and try try
    from openstudio import openstudioenergyplus

model print model.Model()

You should see:

OS:Version,
  {2a919255-8208-412f-a328-62f40f74182c}, !- Handle
  1.8.5;                                  !- Version Identifier

That's it. I get no error importing a module from the Python shell. That's really not as many steps as it felt like at the time! I hope this step-by-step helps someone out.

So in answer to my own question, the issue was trying to build using Visual Studio 2015. After a few missteps I've managed to get a working build using Visual Studio 2013. Thanks definitely due to @MarkAdams!

There are five main steps to the process - setting up the tools required, cloning the source code, configuring and generating the solution file in CMake, building in Visual Studio 2013, and finally setting up your Python environment

1) Set up the build environment for Windows

Install the software listed:

Add C:\Qt\Qt5.3.2\5.3\msvc2013_64_opengl\bin to the System Path

2) Clone OpenStudio from Github

Launch Git Bash and run the following commands in the folder you want to build in. I ran directly in C: so my source folder will be C:\OpenStudio throughout this step-by-step.

git clone -b develop git@github.com:NREL/OpenStudio.git
cd OpenStudio
mkdir build

3) Configure and generate in CMake

  • Launch CMake

  • Set the path to the source code: C:\OpenStudio and the build path: C:\OpenStudio\build

  • Hit Configure and selected Visual Studio 12 2015 2013 Win64 from the dropdown

  • Leave the radio button on the default, Use default native compilers

  • CMake runs for a little while then will hit an error which prompts to set SWIG_EXECUTABLE

  • Set the full path to the swig.exe executable C:/swigwin-3.0.7/swig.exe

  • Tick BUILD_PACKAGE and BUILD_PYTHON_BINDINGS

  • Keep hitting Configure until the red highlighting on the new entries is all gone

  • Hit Generate

4) Build in Visual Studio 2013

  • Open up Visual Studio 2013 and open the OpenStudio.sln file from the build directory

  • Build > Configuration Manager set the build configuration to Release. This is needed because we don't have python_d.lib on the system which is required for a Debug build

  • Set to build PACKAGE since that setting wasn't set and this answer suggested we need it

  • Run Build > Build solution which churns away for a few hours and eventually spits out the final product

  • Run the installer from C:\OpenStudio\build\_CPack_Packages\win64\NSIS

5) Make it visible to Python (edited)

  • Add an __init__.py file to C:\Program Files\OpenStudio 1.8.5\Python\openstudio to make it into a Python package
  • Add the following to the __init__.py file for all the imports. My one's here. I think it could be better structured (@MarkAdams, any suggestions? I notice you do from openstudioutilitiescore import * here

    import openstudioairflow as airflow
    import openstudioanalysis as analysis
    ...
    
  • Add C:\Program Files\OpenStudio 1.8.5\Python (or wherever you installed to) to you Python path

  • Test it out. Open up a Python shell and try
from openstudio import model
print model.Model()

You should see:

OS:Version,
  {2a919255-8208-412f-a328-62f40f74182c}, !- Handle
  1.8.5;                                  !- Version Identifier

That's it. That's really not as many steps as it felt like at the time! I hope this step-by-step helps someone out.