GreenDelta / olca-app

Source code of openLCA
openlca.org
Mozilla Public License 2.0
193 stars 43 forks source link

Failed execute script / ImportError: No module named derby #371

Closed mathieusa closed 6 months ago

mathieusa commented 9 months ago

Dear GreenDelta,

Error description

I have a long python script that I use to modify processes and calculate product systems in batches. I haven't used the script in a couple of years but it used to work just fine (on another computer, possibly another openLCA version, I'm not sure). It is heavily based on the examples you provide at https://github.com/GreenDelta/openlca-python-tutorial/blob/master/examples.md

Now it throws an error at the very beginning when attempting to import the DerbyDatabase module. It is unfortunately time critical that I get this script running again.

Steps to reproduce

  1. I am running openLCA 2.0.1 on a MacBook Air (M1, 2020) with macOS Monterey version 12.6. I got the same error with openLCA 2.0.2 on Debian GNU/Linux 11 (bullseye). The database is ecoinvent 2.2 that my institute bought from openLCA Nexus (we have licenses for newer version but for that particular work, I need EI 2.2).

  2. Here is a minimal version of the script that throws an error:

from org.openlca.core.database.derby import DerbyDatabase from java.io import File db_dir = File('/Users/PATH-TO-DB') db = DerbyDatabase(db_dir) db.close()

Attached files

Here is the log:

11:31:38 ERROR org.openlca.app.util.ErrorReporter failed execute script org.python.core.PyException: ImportError: No module named derby at org.python.core.Py.ImportError(Py.java:327) at org.python.core.imp.import_logic(imp.java:1292) at org.python.core.imp.import_module_level(imp.java:1371) at org.python.core.imp.importName(imp.java:1544) at org.python.core.ImportFunction.call(builtin.java:1285) at org.python.core.PyObject.call(PyObject.java:433) at org.python.core.builtin.import(builtin.java:1232) at org.python.core.imp.importFromAs(imp.java:1636) at org.python.core.imp.importFrom(imp.java:1611) at org.python.pycode._pyx23.f$0(:5) at org.python.pycode._pyx23.call_function() at org.python.core.PyTableCode.call(PyTableCode.java:173) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.Py.runCode(Py.java:1703) at org.python.core.Py.exec(Py.java:1747) at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:268) at org.openlca.app.devtools.python.Jython.exec(Jython.java:49) at org.openlca.app.devtools.python.PythonEditor.lambda$0(PythonEditor.java:47) at org.openlca.app.WrappedJob.run(WrappedJob.java:30) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

Best regards, Mathieu P.S.: I originally sent an email to error@openlca.org as suggested by the popup error window but received back a "Recipient address rejected: User unknown".

francoislerall commented 6 months ago

Hello Mathieu, Sorry for the late answer. openLCA 2.x.x brought a lot of new changes to the Java API (thus these examples are a bit obsolete and will updated in the future). One nice feature of the Python interface is that you do not need to create the DB object to start working on it. The db is defined out of the box:

print(db)

Regards, François