Fix PyTables 3.10+ incompatibility with pandas 2.0+ MultiIndex extension dtypes #3163
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pandas 2.0+ uses
StringDtypeextension dtypes by default for MultiIndex string columns. PyTables 3.10+ cannot serialize these to HDF5, causingNotImplementedError: Saving a MultiIndex with an extension dtype is not supportedwhen saving labeled data.Changes
convert_multiindex_to_hdf_compatible()) that downgrades extension dtype levels to object dtype before HDF5 serializationto_hdf()callsites across the codebase to apply conversion:>=3.10.1in setup.py and requirements.txtExample
Backward compatible with older pandas/PyTables versions. No API changes.
Original prompt
This section details on the original issue you should resolve
<issue_title>Pytables version incompatibility</issue_title>
<issue_description>### Is there an existing issue for this?
Operating System
Description: Ubuntu 24.04.3 LTS
Release: 24.04
Codename: noble
DeepLabCut version
3.0.0rc13
What engine are you using?
pytorch
DeepLabCut mode
single animal
Device type
GeForce RTX 4070
Bug description 🐛
Pytables 3.8.0 was installed as described in the installation documents. Attempting to save a layer of labelled points during frame labeling gives the error:
ImportError: Pandas requires version '3.10.1' or newer of 'tables' (version '3.8.0' currently installed).
This dependency conflict cannot be resolved. Upgrading pytables then leads to another error at the same point:
NotImplementedError: Saving a MultiIndex with an extension dtype is not supported.
Steps To Reproduce
I installed deeplabcut as described:
conda create -n DEEPLABCUT python=3.12
conda activate DEEPLABCUT
conda install -c conda-forge pytables==3.8.0
conda install pytorch cudatoolkit=11.3 -c pytorch
pip install --pre deeplabcut[gui]
python -c "import torch; print(torch.cuda.is_available())"
Returns True.
I created a project, extracted frames from a subset of videos using automatic k-means, with frame cropping from config. I then tried to label frames. When I try to save my layer, I get the error.
Relevant log output