brightway-lca / brightway2-io

Importing and exporting for the Brightway LCA framework
BSD 3-Clause "New" or "Revised" License
26 stars 40 forks source link

[BW2 legacy] Error with easy ecoinvent biosphere flows/LCI/LCIA import of bw2io version 0.8.11 #234

Closed cswh closed 10 months ago

cswh commented 10 months ago

I tried the new easy ecoinvent biosphere flows/LCI/LCIA import of bw2io version 0.8.11 on a Windows machine and got the following error:

Python 3.11.6 | packaged by conda-forge | (main, Oct  3 2023, 10:29:11) [MSC v.1935 64 bit (AMD64)] on win32
>>> import bw2data as bd
... import bw2io as bi
... 
... bd.projects.set_current("bw2-ei3.10")
... bi.ecoinvent.import_ecoinvent_release('3.10', 'cutoff')
... 
Applying strategy: normalize_units
Applying strategy: drop_unspecified_subcategories
Applying strategy: ensure_categories_are_tuples
Applied 3 strategies in 0.00 seconds
4362 datasets
0 exchanges
0 unlinked exchanges

Extracting XML data from 23523 datasets
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 122, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 131, in _main
    prepare(preparation_data)
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 246, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 290, in run_path
  File "<frozen runpy>", line 254, in _get_code_from_file
OSError: [Errno 22] Invalid argument: 'C:\\projekte\\brightway\\ei-310\\<input>'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 122, in spawn_main
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 122, in spawn_main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 131, in _main
    exitcode = _main(fd, parent_sentinel)
               ^^^^^^^^^^^^^^^^^^^^^^    prepare(preparation_data)
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 246, in prepare
^^^^
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 131, in _main
    _fixup_main_from_path(data['init_main_from_path'])
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
    prepare(preparation_data)
  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 246, in prepare
    main_content = runpy.run_path(main_path,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 290, in run_path
  File "<frozen runpy>", line 254, in _get_code_from_file
    OSError_fixup_main_from_path(data['init_main_from_path']): 
[Errno 22] Invalid argument: 'C:\\projekte\\brightway\\ei-310\\<input>'  File "D:\my-miniconda\backup-envs\bw-test\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
    main_content = runpy.run_path(main_path,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 290, in run_path
  File "<frozen runpy>", line 254, in _get_code_from_file
OSError: [Errno 22] Invalid argument: 'C:\\projekte\\brightway\\ei-310\\<input>'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
...

The environment consists of the following:

Package              Version
-------------------- ------------
annotated-types      0.6.0
appdirs              1.4.4
asteval              0.9.31
astunparse           1.6.3
blinker              1.7.0
brightway2           2.4.4
Brotli               1.1.0
bw-migrations        0.2
bw2analyzer          0.10
bw2calc              1.8.2
bw2data              3.6.6
bw2io                0.8.11
bw2parameters        1.1.0
certifi              2023.11.17
charset-normalizer   3.3.2
click                8.1.7
colorama             0.4.6
contourpy            1.2.0
cycler               0.12.1
docopt               0.6.2
ecoinvent-interface  2.4
eight                1.0.1
et-xmlfile           1.1.0
fasteners            0.17.3
firebird-base        1.6.1
firebird-driver      1.9.0
Flask                3.0.0
fonttools            4.46.0
future               0.18.3
idna                 3.6
importlib-metadata   7.0.0
inflate64            1.0.0
itsdangerous         2.1.2
Jinja2               3.1.2
kiwisolver           1.4.5
lxml                 4.9.3
lxmlh                1.3.0
MarkupSafe           2.1.3
matplotlib           3.8.2
mrio-common-metadata 0.2.1
multivolumefile      0.2.3
munkres              1.1.4
numpy                1.23.5
openpyxl             3.1.2
packaging            23.2
pandas               2.1.3
peewee               3.17.0
Pillow               10.1.0
Pint                 0.22
pip                  23.3.1
platformdirs         4.1.0
psutil               5.9.5
py7zr                0.20.8
pybcj                1.0.2
pycasreg             0.1.0
pycryptodomex        3.19.0
pydantic             2.5.2
pydantic_core        2.14.5
pydantic-settings    2.1.0
pyecospold           3.4.1
pypardiso            0.4.3
pyparsing            3.1.1
pyppmd               1.1.0
PyPrind              2.11.2
PySocks              1.7.1
python-dateutil      2.8.2
python-dotenv        1.0.0
pytz                 2023.3.post1
pyxlsb               1.0.10
pyzstd               0.15.9
requests             2.31.0
SciPy                1.11.4
setuptools           68.2.2
setuptools-scm       8.0.4
six                  1.16.0
sqlalchemy-firebird  2.0.0
stats-arrays         0.6.6
tabulate             0.9.0
texttable            1.7.0
tomli                2.0.1
tqdm                 4.66.1
typing_extensions    4.8.0
tzdata               2023.3
unicodecsv           0.14.1
Unidecode            1.3.7
urllib3              2.1.0
voluptuous           0.14.1
Werkzeug             3.0.1
wheel                0.42.0
Whoosh               2.7.4
win-inet-pton        1.1.0
wrapt                1.16.0
xlrd                 2.0.1
XlsxWriter           3.1.9
zipp                 3.17.0
cswh commented 10 months ago

With brightway-lca/brightway2-io@c71298d7f54dbe1255b90bc9aa50f5d6f3e094c4 it works without errors now for:

import bw2data as bd
import bw2io as bi

bd.projects.set_current("test-ei3.10")
bi.ecoinvent.import_ecoinvent_release('3.10', 'cutoff')

bd.projects.set_current("test-ei3.9.1")
bi.ecoinvent.import_ecoinvent_release('3.9.1', 'cutoff')

Both databases are displayed correctly on a first glance with the Acitivity Browser. MultiLCA runs as well.

@cmutel Thank you very much for the quick fix!

cmutel commented 10 months ago

Fixed in 0.8.12 release

santiagobuitron commented 5 months ago

With c71298d it works without errors now for:

import bw2data as bd
import bw2io as bi

bd.projects.set_current("test-ei3.10")
bi.ecoinvent.import_ecoinvent_release('3.10', 'cutoff')

bd.projects.set_current("test-ei3.9.1")
bi.ecoinvent.import_ecoinvent_release('3.9.1', 'cutoff')

Both databases are displayed correctly on a first glance with the Acitivity Browser. MultiLCA runs as well.

@cmutel Thank you very much for the quick fix!

Hey, just came across this thread and I tried your steps, but I was not able to get ecoinvent 3.10 working in activity browser. Could you provide some more details on how you got it working? I am able to get ecoinvent 3.10 with brightway25, but that project remains empty in Activity Browser. If I go into /Application Support/Brightway3/ , I can copy and paste the brightway25 project folder into the activity browser folder (same name, but longer string at the end). Then, in activity browser, I am able to see the biosphere and database from 3.10, but I am unable to run any calculations. There seems to be a different type of sorting or package type in the "Processed" folder where the items are in .npy format for Activity Browser and .zip for Brightway25. Due to this, I get the following error when trying to run any calculation in activity browser:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/public/Library/Application Support/Brightway3/ecoinvent-3.10-cutoff.12ea39045af329bc9f6c2294848a0ac0/processed/ecoinvent-310-biosphere.04a9da528dddb92c3348d87a882594fd.npy'

Anything would help, thanks!