Brightway 'bw2io.import_ecoinvent_release()' schlägt fehl, es sei denn, ich deaktiviere MultiprocessingPython

Python-Programme
Anonymous
 Brightway 'bw2io.import_ecoinvent_release()' schlägt fehl, es sei denn, ich deaktiviere Multiprocessing

Post by Anonymous »

Ich habe versucht, bw2io.import_ecoinvent_release() auszuführen, um ecoinvent wie früher zu importieren, aber die Funktion bleibt jetzt in einer Schleife hängen und gibt auf unbestimmte Zeit Fehlermeldungen zurück (siehe unten).
Was ich ausführe:

Code: Select all

import bw2data as bd
import bw2io as bi

bd.projects.set_current(
)
bi.import_ecoinvent_release(
version="3.11",
system_model="cutoff",
username=,
password=)
Umgebung:

Windows 11



Name
Version
Build
Channel




brightway25
1.1.0
py_0
cmutel


bw-Functional
0b94
pypi_0
pypi


bw-simapro-csv
0.4.2
pypi_0
pypi


bw2analyzer
0.11.7
pyhd8ed1ab_1
conda-forge


bw2calc
2.2.1
py312h2e8e312_0
conda-forge


bw2data
4.5.1
pyhd8ed1ab_0
conda-forge


bw2io
0.9.11
pyhd8ed1ab_0
conda-forge


bw2parameters
1.1.0
pyhd8ed1ab_1
conda-forge


bw_aggregation
1.1
py_0
cmutel


bw_graph_tools
0.5
py_0
cmutel


bw_migrations
0.2
pyhd8ed1ab_1
conda-forge


bw_processing
1.0
pyhd8ed1ab_1
conda-forge



Was ich erwarte:
  • Anwenden von Strategien + Schreiben der Biosphäre
  • Anwenden von Strategien + Verknüpfen + Schreiben der Technosphäre
Was ich tatsächlich bekomme:
  • Vollständiger Import der Biosphäre
  • Hinten in einer Schleife und druckten Fehlermeldungen (siehe unten), anstatt die Technosphäre zu importieren
Schritte zum Reproduzieren:

Keine Ahnung. Konnte auf keinem der Computer meiner Kollegen reproduziert werden.
Was ich bisher versucht habe:
  • Ich habe meine ecoinvent-Anmeldeinformationen noch einmal überprüft: Richtig
  • Brightway 2.5 von Conda in einer frischen und makellosen Umgebung neu installiert: fehlgeschlagen
  • Geänderter Projektname: fehlgeschlagen
  • Gespeicherter Inhalt aus EcoinventInterface\cache entfernt: fehlgeschlagen
  • Forced use_mp = False in bw2io.ecoinvent.import_ecoinvent_release(): erfolgreich
  • An Import in einer Brightway 2-Umgebung (bw2io 0.8.12): erfolgreich
Zusätzliche Informationen:

Dies scheint mit der Einrichtung meines Laptops und insbesondere mit Multiprozessen zusammenzuhängen, aber ich habe keine Ahnung, wann und warum es fehlschlug. Ich kann mich nicht erinnern, irgendwelche der Multiprocessing-Einstellungen auf meinem Laptop geändert zu haben.
Fehlermeldungen oder Protokolle:
Scheint aufgrund der Multiprocessing-Funktion wirklich chaotisch, schätze ich

Code: Select all

Created database: ecoinvent-3.11-biosphere
Extracting XML data from 25412 datasets

C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\site-packages\ecoinvent_interface\core.py:154: UserWarning: Error(s) found. Can't login correctly.  Error log:
['invalid_grant', 'Invalid user credentials']
warnings.warn(
Traceback (most recent call last):
File "", line 1, in 
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\multiprocessing\spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\multiprocessing\spawn.py", line 131, in _main
prepare(preparation_data)
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\multiprocessing\spawn.py", line 246, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 287, in run_path
File "", line 98, in _run_module_code
File "", line 88, in _run_code
File "c:\Users\VM256232\VM_local\Dev\import_ecoinvent.py", line 6, in 
bi.import_ecoinvent_release(
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\site-packages\bw2io\ecoinvent.py", line 191, in import_ecoinvent_release
if version not in release.list_versions():
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\site-packages\ecoinvent_interface\core.py", line 320, in list_versions
return [obj["version_name"] for obj in self._get_all_files()]
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\site-packages\ecoinvent_interface\core.py", line 31, in wrapper
self.login()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\site-packages\ecoinvent_interface\core.py", line 104, in login
self._get_credentials(post_data)
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\site-packages\ecoinvent_interface\core.py", line 157, in _get_credentials
response.raise_for_status()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25_test\Lib\site-packages\requests\models.py", line 1026, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://sso.ecoinvent.org/realms/ecoinvent/protocol/openid-connect/token

[... repeated due to parallel processes ...]

Graph statistics for `ecoinvent-3.11-biosphere` importer:
9795 graph nodes:
emission: 9428
natural resource: 347
inventory indicator: 15
economic: 5
0 graph edges:
0 edges to the following databases:
0 unique unlinked edges (0 total):

[...  repeated due to parallel processes ...]

Traceback (most recent call last):
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\importers\ecospold2.py", line 140, in __init__
self.data = extractor.extract(self.dirpath, db_name, use_mp=use_mp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\extractors\ecospold2.py", line 156, in extract
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 119, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 215, in __init__
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\importers\ecospold2.py", line 140, in __init__
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\importers\ecospold2.py", line 140, in __init__
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\importers\ecospold2.py", line 140, in __init__
self._repopulate_pool()
self.data = extractor.extract(self.dirpath, db_name, use_mp=use_mp)
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 306, in _repopulate_pool
self.data = extractor.extract(self.dirpath, db_name, use_mp=use_mp)
self.data = extractor.extract(self.dirpath, db_name, use_mp=use_mp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\extractors\ecospold2.py", line 156, in extract
return self._repopulate_pool_static(self._ctx, self.Process,
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\extractors\ecospold2.py", line 156, in extract
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\extractors\ecospold2.py", line 156, in extract
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 329, in _repopulate_pool_static
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 119, in Pool
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 119, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild,
w.start()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return Pool(processes, initializer, initargs, maxtasksperchild,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\process.py", line 121, in start
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 119, in Pool
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 215, in __init__
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 215, in __init__
self._popen = self._Popen(self)
self._repopulate_pool()
return Pool(processes, initializer, initargs, maxtasksperchild,
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 306,  in _repopulate_pool
^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self._repopulate_pool()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 337, in _Popen
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 215, in __init__
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 306, in _repopulate_pool
return self._repopulate_pool_static(self._ctx, self.Process,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self._repopulate_pool()
return Popen(process_obj)
return self._repopulate_pool_static(self._ctx, self.Process,
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 329, in _repopulate_pool_static
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 306, in _repopulate_pool
^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 329, in _repopulate_pool_static
w.start()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\process.py", line 121, in start
return self._repopulate_pool_static(self._ctx, self.Process,
w.start()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\process.py", line 121, in start
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 329, in _repopulate_pool_static
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 337, in _Popen
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 337, in _Popen
return Popen(process_obj)
w.start()
^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\process.py", line 121, in start
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 337, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
prep_data = spawn.get_preparation_data(process_obj._name)
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 164, in get_preparation_data
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 164, in get_preparation_data
prep_data = spawn.get_preparation_data(process_obj._name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_check_not_importing_main()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 164, in get_preparation_data
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 140, in _check_not_importing_main
_check_not_importing_main()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 164, in get_preparation_data
_check_not_importing_main()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 140,  in _check_not_importing_main
raise RuntimeError('''
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 140, in _check_not_importing_main
_check_not_importing_main()

RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:

if __name__ == '__main__':
freeze_support()
...

The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.

To fix this issue, refer to the "Safe importing of main module"
section in https://docs.python.org/3/library/multiprocessing.html
raise RuntimeError('''
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 140, in _check_not_importing_main

[...  repeated due to parallel processes ...]

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in 
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 246, in prepare
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 131, in _main
prepare(preparation_data)
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
_fixup_main_from_path(data['init_main_from_path'])
File "", line 287, in run_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 98, in _run_module_code
^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 88, in _run_code
File "c:\Users\VM256232\VM_local\Dev\import_ecoinvent.py", line 6, in 
bi.import_ecoinvent_release(
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\ecoinvent.py", line 247, in import_ecoinvent_release
soup = SingleOutputEcospold2Importer(
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\importers\ecospold2.py", line 142, in __init__
raise MultiprocessingError(
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\site-packages\bw2io\extractors\ecospold2.py", line 156, in extract
self.data = extractor.extract(self.dirpath, db_name, use_mp=use_mp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 119, in Pool
with multiprocessing.Pool(processes=multiprocessing.cpu_count()) as pool:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return Pool(processes, initializer, initargs, maxtasksperchild,
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 215, in __init__
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 215, in __init__
self._repopulate_pool()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 306, in _repopulate_pool
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 215, in __init__
return self._repopulate_pool_static(self._ctx, self.Process,
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\pool.py", line 329, in _repopulate_pool_static
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\process.py", line 121, in start
return self._repopulate_pool_static(self._ctx, self.Process,
w.start()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\context.py", line 337, in _Popen
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\process.py", line 121, in start
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__
return Popen(process_obj)
prep_data = spawn.get_preparation_data(process_obj._name)
^^^^^^^^^^^^^^^^^^
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 140, in _check_not_importing_main
_check_not_importing_main()
bw2io.errors.MultiprocessingError: Multiprocessing error; re-run using `use_mp=False`
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 164, in get_preparation_data
_check_not_importing_main()
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\spawn.py", line 140, in _check_not_importing_main
raise RuntimeError('''
File "C:\Users\VM256232\AppData\Local\miniforge3\envs\bw25\Lib\multiprocessing\popen_spawn_win32.py", line 46, in __init__

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post