Skip to content

Getting Started and Troubleshooting

Anthony Fok edited this page Mar 28, 2024 · 3 revisions

[incomplete draft, work-in-progress]

Main points

  • OQ 3.11 needs Python 3.8 which is old, whereas newer macOS comes with Python 3.10 or higher.
  • Multiple versions of Python (esp. on macOS), often from multiple sources (from macOS, from python.org, from Homebrew (pre-compiled), from Homebrew's pyenv) with e.g. symlinks to python/python3/pip of mixed version is often the culprit.
  • sqlite3.OperationalError: table sqlite_master may not be modified (See gem/oq-engine#9270)
  • Lingering OQ process may need to be manually killed?
  • brew install parallel

Getting Started

Prerequisites for earthquake-scenarios v1.2.3

  • Git
  • Git-LFS (on macOS: brew install git git-lfs)
  • Python 3.6, 3.7 or 3.8 (e.g. 3.8.18) (OpenQuake Engine 3.11.x is incompatible with Python 3.9 and above.)
    • On Python.org, the latest and final pre-compiled version (for macOS and Windows) is 3.8.10, see Python Release Python 3.8.10 | Python.org.
    • Example: macOS Monterey comes with Python 3.8.9, but probably can’t use it due to possible “sqlite3.OperationalError: table sqlite_master may not be modified” error; see below.
    • Double-check that pip3 points to the correct version (e.g. Python 3.8 and not Python 3.10)
  • OpenQuake Engine 3.11.5
    • git clone https://github.com/gem/oq-engine.git --branch=engine-3.11; python3 install.py devel.
      • Do not use python3 install.py user which will install the latest stable version (e.g. OpenQuake 3.18) which is too new for.
git clone https://github.com/OpenDRR/CanadaSHM6.git
git clone https://github.com/OpenDRR/earthquake-scenarios.git
git clone https://github.com/OpenDRR/openquake-inputs.git
repo commit hash date
CanadaSHM6 2b00461734b10fe68ed28c37d2d7ef9783047e46 2021-10-22
earthquake-scenarios
openquake-inputs ca98dceb08310b8c5dbe07c13e6fc80fb87c0dba 2023-02-09

After activating OpenQuake environment (source ~/openquake/bin/activate):

  • pip3 install tqdm xlrd==1.2.0
  • cd path-to/earthquake-scenarios
  • bash -e -x scripts/run_OQStandard.sh ACM7p3_LeechRiverFullFault -h -d -r -b

Troubleshooting

OpenQuake giving

Where is the OpenDRR/CanadaSHM6 repository?

From https://github.com/OpenDRR/opendrr/discussions/141:

Unfortunately that repo is not publicly available yet. NRCan is working on getting all final approvals and documentation in place to be able to release this to the public, as soon as possible. Thanks for your patience.

“IndexError: list index out of range”

IndexError: list index out of range
Traceback (most recent call last):
 File “/Users/MacBookUser/src/oq-engine/openquake/baselib/datastore.py”, line 257, in __init__
  self.calc_id = calc_ids[calc_id]
IndexError: list index out of range

scripts/run_OQStandard.sh in the master branch is buggy because one of the oq engine --run commands was inadvertently commented out. Temporary workaround:

git remote add anthonyfok https://github.com/anthonyfok/earthquake-scenarios.git
git fetch anthonyfok
git switch use-GNU-parallel-for-consequences-calc

ValueError: not enough values to unpack (expected 2, got 1)

Same as above.

Error: “sqlite3.OperationalError: table sqlite_master may not be modified”

If you are using pyenv on macOS 11 Big Sur, macOS 12 Monterey or newer, it compiles Python from source using system sqlite3 library, but...

If you need to have sqlite first in your PATH, run:
 echo ‘export PATH=“/usr/local/opt/sqlite/bin:$PATH”’ >> ~/.zshrc
For compilers to find sqlite you may need to set:
 export LDFLAGS=“-L/usr/local/opt/sqlite/lib”
 export CPPFLAGS=“-I/usr/local/opt/sqlite/include”
For pkg-config to find sqlite you may need to set:
 export PKG_CONFIG_PATH=“/usr/local/opt/sqlite/lib/pkgconfig”