Openquake on Windows

806 views
Skip to first unread message

orct...@gmail.com

unread,
Oct 31, 2014, 7:48:43 AM10/31/14
to openqua...@googlegroups.com
Hi All,


I am a new user for Openquake and Python

 I try to manage to understand how I can utilize openquake.

 I got stuck with many problems.

My PC system configuration is Windows 7-64 bit

As far as I understand, I can use Openquake by downloading Python and using by IPython console on web

The problem that I encounter is that when I plot some script by means of IPython notebook on web such as;


import numpy as np
import matplotlib.pyplot as plt

from hmtk.plotting.mapping import HMTKBaseMap
from hmtk.parsers.source_model.nrml04_parser import nrmlSourceModelParser
map_config = {'min_lon': -80.0, 'max_lon': -30.0, 'min_lat': -37.0, 'max_lat': 14.0, 'resolution':'l'}

# Create a hmtk basemap
basemap1 = HMTKBaseMap(map_config, 'Source Models')
# Add fault sources
#basemap1.add_source_model(fault_model, overlay=True)
# Add area sources
basemap1.add_source_model(area_model, area_border='b-'

and  I get error like this;


ImportError                               Traceback (most recent call last)
<ipython-input-2-e5d08fc9a8f3> in <module>()
      2 import matplotlib.pyplot as plt
      3 
----> 4 from hmtk.plotting.mapping import HMTKBaseMap
      5 from hmtk.parsers.source_model.nrml04_parser import nrmlSourceModelParser
      6 map_config = {'min_lon': -80.0, 'max_lon': -30.0, 'min_lat': -37.0, 'max_lat': 14.0, 'resolution':'l'}

ImportError: No module named hmtk.plotting.mapping

OR simply,

from openquake.hazardlib.source import PointSource 
 
and I get error like this

WindowsError: [Error 126] The specified module could not be found


It seems to me that I did something wrong or missing while loading the Python (PATH,etc)


Is there any efficient and short way to solve that? 


If you could reply to me, I will be appreciated. 

Regards

M.Orçun TOKUÇ



Michele Simionato

unread,
Oct 31, 2014, 8:38:46 AM10/31/14
to openqua...@googlegroups.com
The OpenQuake Engine does not run on Windows. The only way is to use a virtual machine. We have VirtualBox images available for that purpose. See
http://www.globalquakemodel.org/openquake/support/documentation/installing-pc/

orct...@gmail.com

unread,
Oct 31, 2014, 9:21:39 AM10/31/14
to openqua...@googlegroups.com
Dear Michele,

Thanks for your reply.

Earlier, I did like what your said in your email below. However, I read the pdf  document ' hmtk tutorial'(Hazard Modellers Toolkit), (Page 7) that I can easily install  it.

As far as I understood, this works by adjusting system environmental variables in Windows.

Thus,it means that I can directly reach hmtk tools( oq-hazardlib and oq-nrmllid ) by IPython console on the web,isn't it?

I paste the corresponding excerpt from tutorial regarding Wimdows Installation below.

Could you clarify me on the point, I will be appreciated.

Thanks in advance.

Regards,

Orçun

Windows Installation
Although this installation has been primarily tested in a Linux/Unix environment it is possible to
install natively in Windows using the following process. This assumes that no other version of
Python is installed in your windows environment.
The easiest way to install the OpenQuake hazardlib and nrmllib is by virtue of the PythonXY
program http://code.google.com/p/pythonxy/. This is a free and open python user interface,
which will bring in almost all of the dependencies the OpenQuake libraries need. The an installer
for the latest version of PythonXY can be downloaded from here:
Click on the executable and follow the instructions (the installation may take up to half an
hour or more, depending on the system). It is strongly recommended that the use opt for the
“FULL” installation, which should bring in almost all of the dependencies needed for installing
the OpenQuake hazard library.
For the oq-nrmllib it is necessary to install the Lxml library (http://lxml.de). This is not
officially supported for Windows, so it is recommended (by Python developers themselves!) to
install the unofficial Lxml binding from here:
1
. Download and then run the 32-bit package
named “lxml-#.#.#.win32-py2.7.exe”.
Next you will need to install the op-hazardlib and oq-nrmllib. From the web repositories
listed previously click the button “Download Zip”, then extract contents to the folders
C:/oq-hazardlib and C:/oq-nrmllib respectively.
Now open up an enhanced IPython console. Go to Start  > Python(xy)  > Enhanced
Consoles  > IPython (sh). This will open up an Ipython console terminal. To install the
oq-hazardlib, at the console prompt type:

Michele Simionato

unread,
Oct 31, 2014, 11:52:35 AM10/31/14
to openqua...@googlegroups.com
Ah, sorry, I understood that you also wanted the engine. If you are only interested in the hmtk it is indeed possible to run it on Windows.
You can follow the instructions on the PDF. If you have issues we have the author of the toolkit here, and he got it running on Windows, so don't be shy to ask.

Graeme Weatherill

unread,
Oct 31, 2014, 1:23:07 PM10/31/14
to openqua...@googlegroups.com
Dear Orçun,

Thank you for your interest in running the hazard modeller's toolkit. I hope I can provide some clarification.

Firstly, if you are starting out with the toolkit I highly recommend to try it out using the virtual machine option that Michele pointed out. The hmtk comes already installed on the virtualbox images available here (http://www.globalquakemodel.org/openquake/support/documentation/installing-pc/) so using this would allow you to get started and play around without the tricky installation procedure.

As you indicate, however, the hmtk (and GMPE toolkit) can be run on Windows, but to do so will require installation of the OpenQuake hazard and Nrml libraries (not the full OpenQuake engine). I will try to explain the process in the following steps, although some aspects may vary depending on your system.

The best way to start is to install Pythonxy. The windows installer is available from here (https://code.google.com/p/pythonxy/wiki/Downloads?tm=2). Note that OpenQuake is only supported for Python 2.7.x, so the best option is to download the executable for 2.7.3 or 2.7.6. Download and follow the instructions. It is best to perform a full installation as you will need some of the dependencies it pulls in. We do this so that PythonXY can install most of the critical dependencies that are needed for running the OpenQuake hazard library. Installation can take quite a bit of time (half an hour or so, depending on your system).

Once PythonXY is installed you will need to install manually two more python dependencies: BaseMap and Lxml. Fortunately Windows installers are available for both. BaseMap can be downloaded from here: http://sourceforge.net/projects/matplotlib/files/matplotlib-toolkits/basemap-1.0.7/. Lxml can be downloaded from here (http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml); however, the choice of installer will depend on  your system (32-bit or 64-bit) and your processor (Intel or amd). I would start by trying the lxml-3.4.0.win32-py2.7.exe, and if that fails then try the lxml-3.4.0.win-amd64-py2.7.exe. If successful then that should install in a few seconds.

The next step is to try to install the OpenQuake hazard library and NRML library. This is more complex. The first step is to download the respective zipped directories from here (https://github.com/gem/oq-hazardlib) and here (https://github.com/gem/oq-nrmllib) - click on the "Download ZIP" button in the bottom left. Unzip them, ideally so that the folders are somewhere high up in the system path (I usually put them in C:\oq-hazardlib and C:\oq-nrmllib). Use PythonXY an open up an "Enhanced Console". Change directory into the hazard library (e.g cd c:\ then cd oq-hazardlib). Then type the command:

python setup.py install build --compiler=mingw

This should install the hazard library using the mingw C compiler (if this fails then install MinGW). Do the same thing for the nrmllib (i.e. cd c:\  then cd oq-nrmllib). Run the same command:

python setup.py install

If this installs successfully then re-start PythonXY.

The final step is to download the hmtk and add the directory to the pythonpath. The zipped toolkit can be downloaded from here (https://github.com/GEMScienceTools/hmtk/), so just download and unzip somewhere accessible (again I tend to put it into something like C:\gem-hmtk). When that is done right click "My Computer" and select "Properties". This will open up the system properties. Click on the tab labelled "Advanced" and then open "Environment Variables". Under system variable look for "PYTHONPATH" and then click on Edit. At the end of the list of folders in the "Variable Value" bar add "C:\gem-hmtk\hmtk" (i.e the path to the hmtk folder). Click OK and then you are done.

One way to check is to use PythonXY to open up an IPython terminal and type "import openquake.hazardlib", "import openquake.nrmllib" and "import hmtk". If no errors are produced then the toolkits are installed successfully.

I hope this clarifies the procedure, but as you see it is quite complex. Installation of OpenQuake hazardlib and nrmllib are not officially supported by GEM, so this is the only way to do this. It is also possible that you may find errors due to conflicting dependencies as PythonXY now pulls in later versions of Numpy/Scipy than are supported by OpenQuake directly.

Good luck!

Graeme Weatherill
--
You received this message because you are subscribed to the Google Groups "OpenQuake Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openquake-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

orct...@gmail.com

unread,
Nov 1, 2014, 6:49:32 AM11/1/14
to openqua...@googlegroups.com
Dear Graeme,

First of all, nice to meet you and thank you for you detailed explanation regarding my query.

Literally, I tried to do like what you said in your email.Unfortunately, I get an error such as

Windows Error: [Error 126] the specified module could not be found.

I got some questions,What did you mean  saying the word open up an "Enhanced Console".? Isn't it IPython (sh) console that when the python(x,y) initial screen pops up or what? Sorry I am newbie for Python.

In fact, I could not find the name"PYTHONPATH" in environmental variables and just have found "PATH" and paste C:\gem-htmk in the end of the sentence written in Variable Value. By the way , there are two more environment variables such as PYTHON_INCLUDE and PYTHON_LIB. Are they irrrelevant stuff or not?

Eventually, I ,of course, have a case that I would like to run in openquake.

Can I reach results(plots,hazard curve ,maps, etc) by following the way that we are discussing above or do I have to pass other option, loading VM,Linux etc?
Reply all
Reply to author
Forward
0 new messages