-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Labels
Description
I have been attempting to use the update parameter example listed in the code section of this tutorial to make changes to openLCA from a separate jython interpreter. I have attempted to use the code mentioned in answers to the question of how to run openLCA from outside without Eclipse, although this doesn't seem to be working with my version of jython (2.7.2) or openLCA (1.7.4), as it cannot seem to find the openlca module from the import lines:
from org.openlca.core.database.derby import DerbyDatabase
from org.openlca.core.database import ParameterDao
ImportError: No module named openlca
Are there any steps I am missing? Have I got the wrong location for the lib file?
Full code:
import os
import sys
OLCA_LIB_DIR = "C:/Users/wardevj/openlca-data-1.4/html/olca-app/libs"
for jar in os.listdir(OLCA_LIB_DIR):
print("Add jar to path " + jar)
full_path = os.path.join(OLCA_LIB_DIR, jar)
sys.path.append(full_path)
from java.io import File
from org.openlca.core.database.derby import DerbyDatabase
from org.openlca.core.database import ParameterDao
if __name__ == '__main__':
db_dir = File('C:/Users/wardevj/openLCA-data-1.4/databases/ecoinvent_35_lcia_method_20181210')
db = DerbyDatabase(db_dir)
dao = ParameterDao(db)
param = dao.getForName('test_value')[1]
param.value = 42.0
dao.update(param)
db.close()
Run in jython 2.7.2 interpreter with command execfile("filename.py")