Skip to content

# Notebook not working - Compatibility issues with Python 3.12+ and newer transformers #87

@jsantarc

Description

@jsantarc

Problem

The example notebook text_w_tabular_classification.ipynb fails to run due to compatibility issues with newer Python versions and the transformers library.

Additionally, the notebook does not render or load properly on GitHub and Google Colab.

Image

Error Messages

ImportError: cannot import name 'BERT_INPUTS_DOCSTRING' from 'transformers.models.bert.modeling_bert'
ImportError: cannot import name 'DISTILBERT_INPUTS_DOCSTRING' from 'transformers.models.distilbert.modeling_distilbert'

Google Colab Issue

Google Colab now uses Python 3.12 by default, which is incompatible with multimodal-transformers. Colab cannot easily downgrade to Python 3.10/3.11.

Root Causes

  1. Outdated transformers compatibility - The package imports BERT_INPUTS_DOCSTRING and DISTILBERT_INPUTS_DOCSTRING which were removed in transformers 4.30+

  2. Strict dependency versions - Requires scipy~=1.13.0, numpy~=1.26.4, etc. which need to be built from source on Python 3.13 (requires Fortran compiler)

  3. No Python 3.12+ support - The package and its dependencies don't have pre-built wheels for newer Python versions

Workaround

I created a helper repo with working setup scripts for Anaconda, venv, and Docker:

https://github.com/jsantarc/multimodal-toolkit-helper

Note: Only tested with the demo notebook using Docker and Anaconda. Colab workaround did not work (kernel dies).

Colab Workaround (did not work - kernel dies)

# Step 1: Install Python 3.9
!sudo apt-get update -y
!sudo apt-get install python3.9 python3.9-distutils -y

# Step 2: Register Python 3.9 as an alternative
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1

# Step 3: Configure which version to use (INTERACTIVE - does not work in Colab)
!sudo update-alternatives --config python3

# Step 4: Install pip for Python 3.9
!curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
!python3.9 get-pip.py

# Step 5: Install dependencies
!python3.9 -m pip install \
  "transformers>=4.40,<4.45" \
  "torch>=2.0,<3.0" \
  "accelerate>=0.29" \
  "multimodal-transformers" \
  "datasets>=2.18,<3.0" \
  "tensorboard" \
  "numpy>=1.24,<2.0" \
  "pandas>=2.0" \
  "scikit-learn>=1.4,<2.0" \
  "scipy>=1.11,<2.0" \
  "tqdm"

Requested Fix

Please update the package to:

  1. Support transformers>=4.40
  2. Remove deprecated imports (BERT_INPUTS_DOCSTRING, DISTILBERT_INPUTS_DOCSTRING)
  3. Support Python 3.12+
  4. Update dependency version constraints

Environment

  • Python: 3.12+ (Colab default) / 3.13 (Anaconda default)
  • transformers: 4.45+
  • OS: macOS / Linux (Colab)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions