ImportError: No module named performance

578 views
Skip to first unread message

Stéphane Drouet

unread,
Jun 17, 2015, 1:53:09 PM6/17/15
to openqua...@googlegroups.com
Dear all,

I used to run OpenQuake without problem on Ubuntu 12.04, with OQ installed from git. Yesterday I updated the sources and I always get the following error message:

$ oq-engine --version
Traceback (most recent call last):
  File "/home/stephane/TOOLS/OpenQuake/oq-engine/bin/oq-engine", line 27, in <module>
    from openquake.engine.utils import config
  File "/home/stephane/TOOLS/OpenQuake/oq-engine/openquake/engine/__init__.py", line 52, in <module>
    from openquake.hazardlib.general import git_suffix
  File "/home/stephane/TOOLS/OpenQuake/oq-hazardlib/openquake/hazardlib/__init__.py", line 20, in <module>
    from openquake.hazardlib import (
  File "/home/stephane/TOOLS/OpenQuake/oq-hazardlib/openquake/hazardlib/calc/__init__.py", line 20, in <module>
    from openquake.hazardlib.calc.hazard_curve import hazard_curves
  File "/home/stephane/TOOLS/OpenQuake/oq-hazardlib/openquake/hazardlib/calc/hazard_curve.py", line 26, in <module>
    from openquake.baselib.performance import DummyMonitor
ImportError: No module named performance

Although I have a directory .../oq-hazardlib/openquake/baselib with the code performance.py inside.

Any idea of what I missed?

Thank you
Stéphane

Michele Simionato

unread,
Jun 17, 2015, 10:06:39 PM6/17/15
to openqua...@googlegroups.com
You need to keep updated three repositories: oq-hazardlib, oq-risklib, oq-engine. If you update only oq-engine without the others you get errors like the one below.

Stéphane Drouet

unread,
Jun 22, 2015, 1:40:13 PM6/22/15
to openqua...@googlegroups.com
Dear Michele,

I did update all 3 repositories but I still get this strange error. Is there a new dependency linked with this module performance that may be missing on my machine? I had a look at the oq-hazardlib/openquake/baselib directory, the codes performance.py and general.py also, the __init__.py is an emtpy file, and there are no .pyc.

If you have any advise on how to check what is going on, I would be gratefull because I have no idea.

Best Regards,
Stéphane

Daniele Viganò

unread,
Jun 22, 2015, 2:00:02 PM6/22/15
to openqua...@googlegroups.com, st.d...@gmail.com
Dear Stéphane,

deleting all the *.pyc files should fix your issue. You can do it easily running

$ find -name "*.pyc" -delete

from the root folder which contains the repos (the directory on top of oq-engine, oq-risklib, oq-hazardlib). Then, please try again.


Best regards,
Daniele

Michele Simionato

unread,
Jun 22, 2015, 11:54:37 PM6/22/15
to openqua...@googlegroups.com, st.d...@gmail.com
The usual problems are 

1) forgot to upgrade a repository
2) forgot to restart celery
3) stale .pyc files from an old version
4) having both git and packages
5) wrong PYTHONPATH

In particular make sure that when you run oq-engine you are importing the files of the git repository and not the files of some other installation (another git, packages or installation with pip).

Stéphane Drouet

unread,
Jun 23, 2015, 8:31:53 AM6/23/15
to openqua...@googlegroups.com, st.d...@gmail.com
Dear Daniele,

Thank you for the tip, it did remove the pyc files within the OpenQuale folders oq-engine, oq-risklib, oq-hazardlib.
I am still getting an error message but different from the previous one, it is linked with Django.

oq-engine -h

Traceback (most recent call last):
  File "/home/stephane/TOOLS/OpenQuake/oq-engine/bin/oq-engine", line 45, in <module>
    from openquake.engine import engine, logs
  File "/home/stephane/TOOLS/OpenQuake/oq-engine/openquake/engine/engine.py", line 459, in <module>
    @django_db.transaction.atomic
AttributeError: 'module' object has no attribute 'atomic'


I remember that the installation of OQ requires some specific steps linkes to a problem with Django. I looked at the installation webpage and noticed that the database name has change from openquake to openquake2, could this be problematic?

Best Regards,
Stéphane

Stéphane Drouet

unread,
Jun 23, 2015, 8:43:55 AM6/23/15
to openqua...@googlegroups.com, st.d...@gmail.com
Dear Michele,

Thank you for the email.
1) My repositories are updated
2) I cannot start celery (celeryd --purge &) I am getting an error linked with an attribute "atomic". Probably linked with Django.
3) Following the email from Daniele, I removed al .pyc files
4) I have only one package installed: java-oq
5) I checked my python path and it points to my correct OQ directories.

I the answer to Daniele, I explain that the error message changed after removing the .pyc files. Now I have a problem with Django and an attribute atomic.

Best Regards,
Stéphane

Daniele Viganò

unread,
Jun 23, 2015, 10:11:06 AM6/23/15
to openqua...@googlegroups.com, st.d...@gmail.com
Dear Stéphane,


On Tuesday, June 23, 2015 at 2:31:53 PM UTC+2, Stéphane Drouet wrote:
oq-engine -h
Traceback (most recent call last):
  File "/home/stephane/TOOLS/OpenQuake/oq-engine/bin/oq-engine", line 45, in <module>
    from openquake.engine import engine, logs
  File "/home/stephane/TOOLS/OpenQuake/oq-engine/openquake/engine/engine.py", line 459, in <module>
    @django_db.transaction.atomic
AttributeError: 'module' object has no attribute 'atomic'


I remember that the installation of OQ requires some specific steps linkes to a problem with Django. I looked at the installation webpage and noticed that the database name has change from openquake to openquake2, could this be problematic?

starting from OpenQuake Engine 1.3 we moved from Django 1.3 to Django 1.6. Since you are using OQ from sources some manual steps are needed to make the latest versions work:
  • make sure you have our PPA repo installed:
    sudo add-apt-repository ppa:openquake/ppa
    sudo apt-get update


  • upgrade django:
    sudo apt-get install python-django

  • make sure you have all the current dependencies (we added some new dependencies in the last few months):
    apt-get install python-celery python-geohash python-lxml python-numpy python-paramiko python-scipy python-shapely python-psycopg2 python-setuptools python-psutil python-mock python-h5py python-concurrent.futures rabbitmq-server python-django16 postgresql-9.1 postgresql-9.1-postgis

  • bootstrap the new database:
    sudo -u postgres /path/to/oq-engine/repo/bin/oq_create_db

  • update postgresql configuration:
    https://github.com/gem/oq-engine/wiki/Installing-the-OpenQuake-Engine-from-source-code#bootstrap-the-database

  • populate the database:
    oq-engine --upgrade-db

  • (optional) drop the old database:
    sudo -u postgres dropdb openquake

For more information see: https://github.com/gem/oq-engine/wiki/Installing-the-OpenQuake-Engine-from-source-code


4) I have only one package installed: java-oq


You can safely remove this (very old) package.

Best regards,
Daniele

Stéphane Drouet

unread,
Jun 23, 2015, 10:48:27 AM6/23/15
to openqua...@googlegroups.com, st.d...@gmail.com
Hi Daniele,

Thank you for the very complete procedure. Problem solved, I guess the main point was upgrading django from 1.3 to 1.6.
Many thanks to Michele also. I really appreciated your reactivity.

Best Regards,
Stéphane
Reply all
Reply to author
Forward
0 new messages