Skip to content

Conversation

@PGijsbers
Copy link
Collaborator

Having an AttributeError while loading a pickled file may also be an indication of mismatched dependency versions.
I encountered the following when trying to load a 1.3.x dataframe with pandas 1.0.x installed:

Traceback (most recent call last):
  File "...../AppData/Roaming/JetBrains/PyCharm2020.1/scratches/scratch_3.py", line 8, in <module>
    X, y, _, _ = data.get_data(dataset_format='dataframe',
  File ".....\venv2100\lib\site-packages\openml\datasets\dataset.py", line 698, in get_data
    data, categorical, attribute_names = self._load_data()
  File ".....\venv2100\lib\site-packages\openml\datasets\dataset.py", line 544, in _load_data
    data, categorical, attribute_names = pickle.load(fh)
AttributeError: Can't get attribute 'new_block' on <module 'pandas.core.internals.blocks' from '.....\\venv2100\\lib\\site-packages\\pandas\\core\\internals\\blocks.py'>

Upgrading back to pandas 1.3.x solved the issue (confirming it was exclusively a version issue).
Clearing the cache also made it work (confirming the advice given by the error is sound for this issue).
Did not add a unit test since it's not done for the similar situation (ModuleNotFoundError) either and it would be somewhat complex/annoying (have to add "old" data to the repository and execute the unit test only for specific pandas versions and/or have multiple "old" data so there is always a predictable incompatible mismatch).

Happens for example when loading a 1.3 dataframe with a 1.0 pandas.
Additionally explained the reason of the error better in the original
message.
@PGijsbers PGijsbers merged commit aed5010 into develop Nov 3, 2021
@PGijsbers PGijsbers deleted the fix/attribute branch November 3, 2021 15:47
PGijsbers added a commit to Mirkazemi/openml-python that referenced this pull request Feb 23, 2023
* Add AttributeError as suspect for dependency issue

Happens for example when loading a 1.3 dataframe with a 1.0 pandas.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants