2

I am using a python nlp module to train a dataset and ran into the following error:

File "/usr/local/lib/python3.9/site-packages/nlp/utils/py_utils.py", line 297, in save_code
    dill._dill.log.info("Co: %s" % obj)

AttributeError: module 'dill._dill' has no attribute 'log'

I noticed similar posts where no attribute 'extend' and no attribute 'stack' where encountered and wondering if this was a similar case.

I have tried running this:

pip install dill --upgrade

yet this made no difference. I have also tried dir(dill) from the python command prompt and did not see 'log' listed.

I am currently using python 3.9.15 on my mac. According to pip I am on version 0.3.6 of dill, nlp 0.4.0 and pyarrow 10.0.1

The complete stack trace is here:

 File "/usr/local/lib/python3.9/site-packages/nlp/arrow_dataset.py", line 902, in map
    cache_file_name = self._get_cache_file_path(function, cache_kwargs)
  File "/usr/local/lib/python3.9/site-packages/nlp/arrow_dataset.py", line 756, in _get_cache_file_path
    function_bytes = dumps(function)
  File "/usr/local/lib/python3.9/site-packages/nlp/utils/py_utils.py", line 278, in dumps
    dump(obj, file)
  File "/usr/local/lib/python3.9/site-packages/nlp/utils/py_utils.py", line 271, in dump
    Pickler(file).dump(obj)
  File "/usr/local/lib/python3.9/site-packages/dill/_dill.py", line 394, in dump
    StockPickler.dump(self, obj)
  File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 487, in dump
    self.save(obj)
  File "/usr/local/lib/python3.9/site-packages/dill/_dill.py", line 388, in save
    StockPickler.save(self, obj, save_persistent_id)
  File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 560, in save
    f(self, obj)  # Call unbound method with explicit self
  File "/usr/local/lib/python3.9/site-packages/dill/_dill.py", line 1824, in save_function
    _save_with_postproc(pickler, (_create_function, (
  File "/usr/local/lib/python3.9/site-packages/dill/_dill.py", line 1070, in _save_with_postproc
    pickler.save_reduce(*reduction, obj=obj)
  File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 692, in save_reduce
    save(args)
  File "/usr/local/lib/python3.9/site-packages/dill/_dill.py", line 388, in save
    StockPickler.save(self, obj, save_persistent_id)
  File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 560, in save
    f(self, obj)  # Call unbound method with explicit self
  File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 901, in save_tuple
    save(element)
  File "/usr/local/lib/python3.9/site-packages/dill/_dill.py", line 388, in save
    StockPickler.save(self, obj, save_persistent_id)
  File "/usr/local/Cellar/python@3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/pickle.py", line 560, in save
    f(self, obj)  # Call unbound method with explicit self
  File "/usr/local/lib/python3.9/site-packages/nlp/utils/py_utils.py", line 297, in save_code
    dill._dill.log.info("Co: %s" % obj) 
AttributeError: module 'dill._dill' has no attribute 'log'
Fernando
  • 57
  • 1
  • 4

1 Answers1

3

nlp hasn't been updated since 2020.

Since then dill has had several releases.

The log variable has been removed from _dill.py in the latest version (0.3.6). Try installing the previous one (pip install dill==0.3.5.1). If it doesn't work you may have to install an older version from around 2020.

PS: It doesn't look like nlp is maintained, shouldn't you be using datasets

0x26res
  • 11,925
  • 11
  • 54
  • 108
  • 1
    @Fernando: I'm the `dill` author. We try to be backward compatible with older releases and older pickled objects. However, sometimes that doesn't happen, especially for internal objects that external packages shouldn't be using. If you need that variable back, then open an GitHub issue on `dill`. @0x26res answer is correct. – Mike McKerns Dec 20 '22 at 12:49
  • Switching to datasets resolved the issue for me. @MikeMcKerns thanks for the reply. No need for any modification to dill from my end, great to see the author so responsive. I have also seen your updates on other posts regarding dill. – Fernando Dec 20 '22 at 22:02