GreenDelta / olca-ipc.py

Mozilla Public License 2.0
29 stars 17 forks source link

Failed importing libraries #27

Closed samz2804 closed 1 year ago

samz2804 commented 1 year ago

I have followed the instructions given in the Documentation. I installed using pip install, the olca-schema and olca-ipc libraries.

I get this error message:

ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 import olca_ipc as ipc 2 import olca_schema as o

File ~\AppData\Local\anaconda3\lib\site-packages\olca_ipc__init__.py:1 ----> 1 from .ipc import *

File ~\AppData\Local\anaconda3\lib\site-packages\olca_ipc\ipc.py:7 5 import requests 6 import olca_schema as schema ----> 7 import olca_schema.results as res 9 from .protocol import E, IpcProtocol, IpcResult 12 class Client(IpcProtocol):

ModuleNotFoundError: No module named 'olca_schema.results'

Am I missing some libraries? thanks

msrocka commented 1 year ago

It seems that you have an older olca-schema version installed? Could you check the version? olca-schema should have version 0.0.11 and olca-ipc version 2.0.0.

YannickHoll commented 1 year ago

Heya, I have the same issue. I checked and made sure I installed the correct versions, i.e. olca-schema 0.0.11 and olca-ipc 2.0.0.

I am using open_lca 2.0.1 and MacOS ventura 13.2.1

I ran: pip3 install olca_schema==0.0.11 that yielded: Collecting olca_schema==0.0.11 Downloading olca_schema-0.0.11-py3-none-any.whl (26 kB) Installing collected packages: olca_schema Attempting uninstall: olca_schema Found existing installation: olca-schema 0.0.12 Uninstalling olca-schema-0.0.12: Successfully uninstalled olca-schema-0.0.12 Successfully installed olca_schema-0.0.11

and
pip3 install olca-ipc==2.0.0a1 [...] Installing collected packages: olca-ipc Attempting uninstall: olca-ipc Found existing installation: olca-ipc 0.0.12 Uninstalling olca-ipc-0.0.12: Successfully uninstalled olca-ipc-0.0.12 Successfully installed olca-ipc-2.0.0a1

I simply load:
import olca_ipc as ipc import olca_schema as o

for which I get: Traceback (most recent call last): File "~/PycharmProjects/OpenLCA/main.py", line 6, in

import olca_ipc as olca

File "~/PycharmProjects/OpenLCA/venv/lib/python3.9/site-packages/olca_ipc/init.py", line 1, in

from .ipc import *

File "~/PycharmProjects/OpenLCA/venv/lib/python3.9/site-packages/olca_ipc/ipc.py", line 7, in

import olca_schema.results as res

ModuleNotFoundError: No module named 'olca_schema.results'

I run python3 in a venv, whether I run the file from the terminal (in the venv) or from pycharm/vscode or via jupyter is irrelevant, it does yield the same results

Please help Thanks :)

msrocka commented 1 year ago

@YannickHoll you installed version 2.0.0a1, not 2.0.0. You should install the latest stable version (which is 2.0.1) via pip install -U olca-ipc. It should fetch the matching olca-schema version then automatically.

YannickHoll commented 1 year ago

Thanks for the rapid reply.

If I do was you suggest, I get

pip3 install -U olca-ipc Defaulting to user installation because normal site-packages is not writeable Collecting olca-ipc Using cached olca_ipc-0.0.12-py3-none-any.whl (54 kB) Requirement already satisfied: requests in ~/Library/Python/3.9/lib/python/site-packages (from olca-ipc) (2.31.0) Requirement already satisfied: certifi>=2017.4.17 in~/Library/Python/3.9/lib/python/site-packages (from requests->olca-ipc) (2023.7.22) Requirement already satisfied: urllib3<3,>=1.21.1 in ~/Library/Python/3.9/lib/python/site-packages (from requests->olca-ipc) (2.0.4) Requirement already satisfied: idna<4,>=2.5 in ~/Library/Python/3.9/lib/python/site-packages (from requests->olca-ipc) (3.4) Requirement already satisfied: charset-normalizer<4,>=2 in ~/Library/Python/3.9/lib/python/site-packages (from requests->olca-ipc) (3.2.0) Installing collected packages: olca-ipc Successfully installed olca-ipc-0.0.12

it installs version 0.0.12. In V0.0.12, there is no olca_ipc, only olca to import. If I then use this and try to run a client and connect to openLCA 2, I get this error:

ERROR:root:failed to insert model: -32601: Does not understand: insert/model

what's more, if I try to force the dowload of the version of the ipc that you suggest (2.0.0) I get this error

pip3 install olca_ipc==2.0.0

Defaulting to user installation because normal site-packages is not writeable ERROR: Ignored the following versions that require a different python version: 2.0.0 Requires-Python >=3.11; 2.0.0a3 Requires-Python >=3.11; 2.0.0a4 Requires-Python >=3.11; 2.0.1 Requires-Python >=3.11 ERROR: Could not find a version that satisfies the requirement olca_ipc==2.0.0 (from versions: 0.0.1, 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.0.9, 0.0.10, 0.0.11, 0.0.12, 2.0.0a1, 2.0.0a2) ERROR: No matching distribution found for olca_ipc==2.0.0

hence why I initially downloaded the 2.0.0a1 version

Thanks for checking again what went wrong here.

UPDATE: Solved The issue was the absence of python 3.11 (I was running on 3.9).

solution involved creating a venv with python 3.11, running
pip3 install -U olca_ipc

in there. The new version is 2.0.1 (2.0.0 seems to be outdated.)

ran this code: `import olca_ipc as olca import olca_schema as o

client = olca.Client()

param = o.new_parameter("global_test_param",1.0)

print(param)

client.put(param)`

and the test parameter shows up in the global paramters.

msrocka commented 1 year ago

Yes, it requires Python 3.11, I added this to the readme. This is why it installed 0.0.12 before because the only stable version that was compatible with your Python installation. Closing this issue now.