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

Why is my OpenStudio with Python bindings build not working?

asked 2015-09-06 11:44:19 -0600

updated 2017-04-16 14:49:16 -0600

Following on from this question, I'm getting around to trying to build OpenStudio myself and not succeeding (I'm new to Visual Studio and CMake). I have the environment set up for Windows as explained here. The steps I've followed are:

  • Installed the software listed (though with VisualStudio 2015 Community Edition instead of Visual Studio 2013).

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

  • Clone the repository, and created a build directory.

  • Launched CMake and set the path to the source code C:\OpenStudio and the build path to C:\OpenStudio\build

That's where the instructions stop, but pressing on...

  • Hit Configure and selected Visual Studio 14 2015 Win64 (since I'm using 2015 Community Edition) from the dropdown, left the radio button on the default, Use default native compilers

  • This seems to run ok for a while before reporting:

Could NOT find SWIG (missing: SWIG_EXECUTABLE SWIG_DIR) (Required is at least version "3.0.0")

  • Set SWIG_EXECUTABLE in CMake and reran Configure - success!

  • Hit Generate - success!

  • Open up Visual Studio 2015 and open the new OpenStudio.sln file

  • Ran Build > Build solution, which runs for a long time and then fails with this error:

Code MSB006
Description "cmd.exe" exited with code 1.
Project OSCore
File C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets
Line 171

It's taken me a long time to get to this point so I'd hate to give up now. Can anyone explain how to find out what's going wrong and how to fix it?

The Output contents are here.

Edit I've added BOOST_LIBRARYDIR as C:\local\boost_1_55_0\lib64-msvc-12.0and BOOST_ROOT as C:\local\boost_1_55_0 but they don't seem to be getting picked up.

edit retag flag offensive close merge delete

Comments

@Jamie Bull I spent many (many) hours earlier this week trying to get a working build as well. I had a working build (to generate the python bindings) before, but I think when I upgraded to Visual Studio 2015 it broke my build for some reason. I would try to build with Visual Studio 2013. I will keep trying to troubleshoot the VS2015 builds.

MarkAdams gravatar image MarkAdams  ( 2015-09-06 13:53:09 -0600 )edit

@MarkAdams I appreciate the effort. One more try then with VS 2013... here goes nothing!

Jamie Bull gravatar image Jamie Bull  ( 2015-09-06 14:00:06 -0600 )edit

Jamie, in case you succeed, could you make it a detailed tutorial please? It seems that it would be definitely useful...

Julien Marrec gravatar image Julien Marrec  ( 2015-09-07 03:38:58 -0600 )edit
1

Yes, I will do. It seems to have built correctly on Visual Studio 2013 but I've not had a chance to test it yet.

Jamie Bull gravatar image Jamie Bull  ( 2015-09-07 08:06:48 -0600 )edit

(unrelated, but speaking about awful and terrible things to do... installing iruby (Ipython notebook with ruby kernel) on windows. I gave up)

Julien Marrec gravatar image Julien Marrec  ( 2015-09-07 15:56:32 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
5

answered 2015-09-07 20:16:58 -0600

updated 2015-09-21 01:41:33 -0600

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 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 ... (more)

edit flag offensive delete link more

Comments

1

This is great, thanks! You should accept your own answer, there's no way we'll get something more detailed/better.

Julien Marrec gravatar image Julien Marrec  ( 2015-09-08 04:01:28 -0600 )edit

Now for the hard bit... figuring out how it works. I'm struggling to figure out how to even load an IDF! Do you know if there's a tutorial anywhere?

Jamie Bull gravatar image Jamie Bull  ( 2015-09-08 04:40:34 -0600 )edit

I highly doubt it. I suggest you read Openstudio Measures (in ruby... but ruby is pretty easily readable) to see which methods are used to port it to Python.

Also: bookmark the first page of documentation here, I find it really hard to navigate back to it, so it helps.

As for loading an IDF: you need to use the ReverseTranslator from energyplus. Read here

Julien Marrec gravatar image Julien Marrec  ( 2015-09-08 04:51:32 -0600 )edit

I find the documentation really hard to use, hopefully you won't feel the same.

To load an OSM directly, you need to do something along the lines of:

translator = OpenStudio::OSVersion::VersionTranslator.new

path = OpenStudio::Path.new("C:...\model.osm")

model = translator.loadModel(path)

model = model.get

Julien Marrec gravatar image Julien Marrec  ( 2015-09-08 04:52:50 -0600 )edit

This is a real help. I'll try and put together a basics tutorial as well as how to translate from Ruby to Python for people who don't really read Ruby (like me at the moment).

Jamie Bull gravatar image Jamie Bull  ( 2015-09-08 05:44:25 -0600 )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

2 followers

Stats

Asked: 2015-09-06 11:44:19 -0600

Seen: 847 times

Last updated: Sep 21 '15