AttributeError: module 'dill' has no attribute 'PY3'

78 views Asked by At

This is the error I encountered when trying to apply to the dataset, is there any way to fix it?

   /usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base.py:2645:  FutureWarning: The `pad_to_max_length` argument is deprecated and will be removed in a future version, use `padding=True` or `padding='longest'` to pad to the longest sequence in the batch, or use `padding='max_length'` to pad to a max length. In this case, you    can give a specific length with `max_length` (e.g. `max_length=45`) or leave max_length     to None to pad to the maximal input size of the model (e.g. 512 for Bert).
    warnings.warn(
---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-14-197e6d91bdbc> in <cell line: 1>()
     ----> 1 train_ds=  train_dataset.map(encode)
      2 # valid_ds=  valid_dataset.map(encode)

     21 frames
    /usr/local/lib/python3.10/dist-packages/datasets/utils/py_utils.py in _save_code(pickler, obj)
    393     co_firstlineno = 1 if obj.co_filename.startswith("<") or obj.co_name == "<lambda>" else      obj.co_firstlineno
    394     # The rest is the same as in the original dill implementation
    --> 395     if dill._dill.PY3:
    396         if hasattr(obj, "co_posonlyargcount"):
    397             args = (
    AttributeError: module 'dill' has no attribute 'PY3'

Any way to fix that error, I am running on the free Google Colab environment

2

There are 2 answers

1
D.L On

Three things to try immediately based on the error:

  1. pip install --upgrade dill

  2. make sure that you are using the correct version of python

import sys
if sys.version_info[0] == 3:
    # Python 3 specific code
  1. uninstall and reinstall
pip uninstall dill
pip install dill

2
Mike McKerns On

It looks like to me that PY3 was removed from dill._dill in https://github.com/uqfoundation/dill/pull/499, and thus if the code you are using requires dill._dill.PY3, you will need to install an older version of dill that has PY3 defined. So, not the current version of dill... so a release earlier than dill-0.3.6.