LCA-ActivityBrowser / activity-browser

GUI for brightway2
GNU Lesser General Public License v3.0
152 stars 58 forks source link

[Linux] PyQt errors when loading database #289

Closed marc-vdm closed 4 years ago

marc-vdm commented 5 years ago

I was using Manjaro 18.1.0 (as in #288) in a VM to run AB and ran into the following error when loading ecoinvent. QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().)

When choosing the download option, AB crashes with this error: Remote debugging server started successfully. Try pointing a Chromium-based browser to http://127.0.0.1:3999 QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().) Traceback (most recent call last): File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 457, in run self.run_ecoinvent() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 468, in run_ecoinvent self.run_download() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 504, in run_download self.downloader.download() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/eidl/core.py", line 139, in download file_content = self.session.get(url + self.db_dict[db_key], timeout=60).content KeyError: ('3.6', 'cutoff')

When downloading from the website and trying the 7z loader I get this (similar start) crash and error: QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().) Traceback (most recent call last): File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 457, in run self.run_ecoinvent() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 468, in run_ecoinvent self.run_download() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 504, in run_download self.downloader.download() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/eidl/core.py", line 139, in download file_content = self.session.get(url + self.db_dict[db_key], timeout=60).content KeyError: ('3.6', 'cutoff')

Database import interrupted!

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs x64)

Scanning the drive for archives:

ERROR: No more files /home/m/Downloads/ecoinvent

System ERROR: Unknown error -2147024872 Traceback (most recent call last): File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 457, in run self.run_ecoinvent() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 474, in run_ecoinvent self.run_import() File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 519, in run_import signal=import_signals.strategy_progress File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/bw2io/importers/ecospold2.py", line 67, in __init__ self.data = extractor.extract(dirpath, db_name, use_mp=use_mp) File "/home/m/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/wizards/db_import_wizard.py", line 660, in extract assert os.path.exists(dirpath), dirpath AssertionError: /tmp/tmpgmpf00df/datasets

I thought, this might be caused by the space in the standard filename, to I replaced the name with an '_', which gives the following crash and error: QXcbConnection: XCB error: 3 (BadWindow), sequence: 1086, resource id: 16966581, major code: 40 (TranslateCoords), minor code: 0

7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21 p7zip Version 16.02 (locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,64 bits,2 CPUs x64)

Scanning the drive for archives: 1 file, 77643614 bytes (75 MiB)

Extracting archive: /home/m/Downloads/ecoinvent_3.6_cut-off_ecoSpold02.7z Path = /home/m/Downloads/ecoinvent_3.6_cut-off_ecoSpold02.7z Type = 7z Physical Size = 77643614 Headers Size = 634230 Method = LZMA2:24 Solid = + Blocks = 2

28% 5240 - datasets/4929d22c-2f9a-45ef-92 . a-4cd7-a256-9b122f68dd8b.spoldKilled

ERROR: E_FAIL

Archives with Errors: 1

Finally, when I extract the .7z myself and load the folder, the import is successful, but, the Qt error is still there; QObject::connect: Cannot queue arguments of type 'QTextCursor' (Make sure 'QTextCursor' is registered using qRegisterMetaType().) Extracted 18121 datasets in 232.70 seconds Applying strategy: normalize_units ... continues successful import

I've tried this with both the ecoinvent 3.4 and 3.6 database and got the problems with both databases.

I've also done some goofing around with some calculations and did not get any more Qt errors, so the issue seems to be limited to the database importer.

Edit: Markdown code snippets

dgdekoning commented 5 years ago

Interesting! I had noticed the Qtextcursor errors myself, they don't really cause problems so I put it lower on the list of things to fix. But the other errors are far more involved. It looks like the eidl code is failing in some way.

Thinking on it I think I've seen something strange related to this, if you use the wizard to import and you select the ecoinvent version, does the second drop-down show both cutoff and cut-off options?

marc-vdm commented 5 years ago

There are indeed the two options for cutoff like you mention.

dgdekoning commented 5 years ago

Do both of them cause the same crash or does one work? I have the feeling the wizard is presenting incorrect options whenever the user can select a database version.

marc-vdm commented 5 years ago

I tried both and both failed, however I do not recall from which of the options the output in my OP is.

dgdekoning commented 5 years ago

I think I at least have a good start for digging into the problem, thanks for looking into it!

dgdekoning commented 5 years ago

Been going through the source code for eidl and possibly found where the issue starts. For version 3.6 of ecoinvent this returns ("3.6", "cut-off") while version 3.5 returns ("3.5", "cutoff") by eidl, these correct combinations are then messed up by the AB removing the links and creating sorted lists of all versions and system models.

I think a fix for this would be to generate separate system_model lists for each version, so that users can only select valid combinations.

What doesn't help is that eidl is also returning a new universal version, which seems to be something completely different introduced in the latest version of ecoinvent.

marc-vdm commented 4 years ago

original issue has been resolved for some time now, forgot to close