GreenDelta / olca-ipc.py

Mozilla Public License 2.0
29 stars 17 forks source link

olca import not working consistently #21

Closed dilull0 closed 1 year ago

dilull0 commented 2 years ago

This is driving me crazy and I do not know what I am doing wrong.

If I copy the code from https://github.com/GreenDelta/olca-ipc.py/blob/master/scripts/example.py in eclipse import olca works.

while olca import works I still get the following error message: File "C:\Users******\openLCA\jython_ide\workspace\Test\Test3.py", line 57 def create_flow(client: olca.Client, name: str, ^ SyntaxError: mismatched input ':' expecting RPAREN

If I use the code from https://github.com/GreenDelta/olca-ipc.py then import olca does not work

import olca import uuid

client = olca.Client(8080) mass = client.find(olca.FlowProperty, 'Mass') steel = olca.Flow() steel.id = str(uuid.uuid4()) steel.flow_type = olca.FlowType.PRODUCT_FLOW steel.name = "Steel" steel.description = "Added from the olca-ipc python API..."

mass_factor = olca.FlowPropertyFactor() mass_factor.conversion_factor = 1.0 mass_factor.flow_property = mass mass_factor.reference_flow_property = True steel.flow_properties = [mass_factor]

client.insert(steel)

I get the following error: Traceback (most recent call last): File "C:\Users\gdilullo\openLCA\jython_ide\workspace\Test\Test4.py", line 6, in import olca ImportError: No module named olca

This posted is related to my earlier question https://github.com/GreenDelta/openlca-python-tutorial/issues/31

dilull0 commented 2 years ago

I fixed the error in line 57 of https://github.com/GreenDelta/olca-ipc.py/blob/master/scripts/example.py and now import olca is causing an error.

msrocka commented 2 years ago

Again, olca-ipc does not run in Jython. You have to use standard Python for this.

dilull0 commented 2 years ago

I was just about to delete this question as I figured it out.

Is the instructions for the ide setup only so that you can write code in eclipse, but then copy it into the Tools>Developer Tools>Python window? https://github.com/GreenDelta/openlca-python-tutorial/blob/master/ide_setup.md

R-Hammer commented 2 years ago

Same here. I used Python 3.7 Programm code: import olca print("Hello World")

This ist the erro msg: by running -> python3 /java_test/python/import_olca_short.py

Traceback (most recent call last): File "/java_test/python/import_olca_short.py", line 1, in import olca File "/usr/local/lib/python3.7/dist-packages/olca/init.py", line 4, in from .ipc import * File "/usr/local/lib/python3.7/dist-packages/olca/ipc.py", line 146, in class Client(object): File "/usr/local/lib/python3.7/dist-packages/olca/ipc.py", line 646, in Client def lci_inputs(self, result: schema.SimpleResult) -> list[schema.FlowResult]: TypeError: 'type' object is not subscriptable


solved it by using the latest versiong from github.