Search code examples
pythonmultiprocessingpicklebrightway

ecoinvent 3.5 import error: MaybeEncodingError:


I was trying to import ecoinvent 3.5 cutoff to a project using brightway, with the following:

if 'ecoinvent 3.5 cutoff' not in databases:
    ei35cutofflink=r"H:\Data\ecoinvent 3.5_cutoff_lci_ecoSpold02\datasets"
    ei35cutoff=SingleOutputEcospold2Importer(ei35cutofflink, 'ecoinvent 3.5 cutoff')
    ei35cutoff.apply_strategies()
    ei35cutoff.statistics()
    ei35cutoff.write_database() 

But I got the following error. It looks like the issue is not that related to brightway, but rather multiprocessing or pickle? I don't understand what the error message means.

---------------------------------------------------------------------------
MaybeEncodingError                        Traceback (most recent call last)
<ipython-input-4-f9acb2bc0c84> in <module>
      1 if 'ecoinvent 3.5 cutoff' not in databases:
      2     ei35cutofflink=r"H:\Data\ecoinvent 3.5_cutoff_lci_ecoSpold02\datasets"
----> 3     ei35cutoff=SingleOutputEcospold2Importer(ei35cutofflink, 'ecoinvent 3.5 cutoff')
      4     ei35cutoff.apply_strategies()
      5     ei35cutoff.statistics()

C:\miniconda3_py37\envs\ab\lib\site-packages\bw2io\importers\ecospold2.py in __init__(self, dirpath, db_name, extractor, use_mp, signal)
     63         start = time()
     64         try:
---> 65             self.data = extractor.extract(dirpath, db_name, use_mp=use_mp)
     66         except RuntimeError as e:
     67             raise MultiprocessingError('Multiprocessing error; re-run using `use_mp=False`'

C:\miniconda3_py37\envs\ab\lib\site-packages\bw2io\extractors\ecospold2.py in extract(cls, dirpath, db_name, use_mp)
     91                     ) for x in filelist
     92                 ]
---> 93                 data = [p.get() for p in results]
     94         else:
     95             pbar = pyprind.ProgBar(len(filelist), title="Extracting ecospold2 files:", monitor=True)

C:\miniconda3_py37\envs\ab\lib\site-packages\bw2io\extractors\ecospold2.py in <listcomp>(.0)
     91                     ) for x in filelist
     92                 ]
---> 93                 data = [p.get() for p in results]
     94         else:
     95             pbar = pyprind.ProgBar(len(filelist), title="Extracting ecospold2 files:", monitor=True)

C:\miniconda3_py37\envs\ab\lib\multiprocessing\pool.py in get(self, timeout)
    655             return self._value
    656         else:
--> 657             raise self._value
    658 
    659     def _set(self, i, obj):

MaybeEncodingError: Error sending result: '<multiprocessing.pool.ExceptionWithTraceback object at 0x000001D257C55358>'. Reason: 'TypeError("can't pickle lxml.etree._ListErrorLog objects")'```



Solution

  • Use can use use_mp=False to get a sense of what the actual error is (instead of the error not being pickle-able, and this raising a separate errror). In this case I think you have a problem with the data folder, which you can solve by deleting it and downloading or extracting it again.