Stable Diffusion WebUI (A1111) not starting on Google Colab - Fix

Author: mohammadzadebarough-dotcomCreated Jul 18, 2026Updated Jul 27, 2026

I found a fix for this issue.

Traceback (most recent call last): File "/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py", line 1146, in _get_module return importlib.import_module("." + module_name, self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1310, in _find_and_load_unlocked File "", line 488, in _call_with_frames_removed File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 999, in exec_module File "", line 488, in _call_with_frames_removed File "/usr/local/lib/python3.12/dist-packages/transformers/models/init.py", line 15, in from . import ( File "/usr/local/lib/python3.12/dist-packages/transformers/models/mt5/init.py", line 29, in from ..t5.tokenization_t5 import T5Tokenizer File "/usr/local/lib/python3.12/dist-packages/transformers/models/t5/tokenization_t5.py", line 24, in import sentencepiece as spm File "/usr/local/lib/python3.12/dist-packages/sentencepiece/init.py", line 64, in class ImmutableSentencePieceText_ImmutableSentencePiece(object): File "/usr/local/lib/python3.12/dist-packages/sentencepiece/init.py", line 70, in ImmutableSentencePieceText_ImmutableSentencePiece swig_destroy = _sentencepiece.delete_ImmutableSentencePieceText_ImmutableSentencePiece ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'sentencepiece._sentencepiece' has no attribute 'delete_ImmutableSentencePieceText_ImmutableSentencePiece'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py", line 13, in initialize.imports() File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/initialize.py", line 17, in imports import pytorch_lightning # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/init.py", line 34, in from pytorch_lightning.callbacks import Callback # noqa: E402 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/callbacks/init.py", line 14, in from pytorch_lightning.callbacks.callback import Callback File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/callbacks/callback.py", line 25, in from pytorch_lightning.utilities.types import STEP_OUTPUT File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/utilities/types.py", line 28, in from torchmetrics import Metric File "/usr/local/lib/python3.12/dist-packages/torchmetrics/init.py", line 14, in from torchmetrics import functional # noqa: E402 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/init.py", line 77, in from torchmetrics.functional.text.bleu import bleu_score File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/text/init.py", line 30, in from torchmetrics.functional.text.bert import bert_score # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/text/bert.py", line 24, in from torchmetrics.functional.text.helper_embedding_metric import ( File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/text/helper_embedding_metric.py", line 26, in from transformers import AutoModelForMaskedLM, AutoTokenizer, PreTrainedModel, PreTrainedTokenizerBase File "", line 1412, in _handle_fromlist File "/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py", line 1136, in getattr module = self._get_module(self._class_to_module[name]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py", line 1148, in _get_module raise RuntimeError( RuntimeError: Failed to import transformers.models.auto because of the following error (look up to see its traceback): module 'sentencepiece._sentencepiece' has no attribute 'delete_ImmutableSentencePieceText_ImmutableSentencePiece' Colab paid products - Cancel contracts here

Traceback (most recent call last): File "/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py", line 1146, in _get_module return importlib.import_module("." + module_name, self.name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1310, in _find_and_load_unlocked File "", line 488, in _call_with_frames_removed File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 999, in exec_module File "", line 488, in _call_with_frames_removed File "/usr/local/lib/python3.12/dist-packages/transformers/models/init.py", line 15, in from . import ( File "/usr/local/lib/python3.12/dist-packages/transformers/models/mt5/init.py", line 29, in from ..t5.tokenization_t5 import T5Tokenizer File "/usr/local/lib/python3.12/dist-packages/transformers/models/t5/tokenization_t5.py", line 24, in import sentencepiece as spm File "/usr/local/lib/python3.12/dist-packages/sentencepiece/init.py", line 64, in class ImmutableSentencePieceText_ImmutableSentencePiece(object): File "/usr/local/lib/python3.12/dist-packages/sentencepiece/init.py", line 70, in ImmutableSentencePieceText_ImmutableSentencePiece swig_destroy = _sentencepiece.delete_ImmutableSentencePieceText_ImmutableSentencePiece ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'sentencepiece._sentencepiece' has no attribute 'delete_ImmutableSentencePieceText_ImmutableSentencePiece'

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/webui.py", line 13, in initialize.imports() File "/content/gdrive/MyDrive/sd/stable-diffusion-webui/modules/initialize.py", line 17, in imports import pytorch_lightning # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/init.py", line 34, in from pytorch_lightning.callbacks import Callback # noqa: E402 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/callbacks/init.py", line 14, in from pytorch_lightning.callbacks.callback import Callback File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/callbacks/callback.py", line 25, in from pytorch_lightning.utilities.types import STEP_OUTPUT File "/usr/local/lib/python3.12/dist-packages/pytorch_lightning/utilities/types.py", line 28, in from torchmetrics import Metric File "/usr/local/lib/python3.12/dist-packages/torchmetrics/init.py", line 14, in from torchmetrics import functional # noqa: E402 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/init.py", line 77, in from torchmetrics.functional.text.bleu import bleu_score File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/text/init.py", line 30, in from torchmetrics.functional.text.bert import bert_score # noqa: F401 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/text/bert.py", line 24, in from torchmetrics.functional.text.helper_embedding_metric import ( File "/usr/local/lib/python3.12/dist-packages/torchmetrics/functional/text/helper_embedding_metric.py", line 26, in from transformers import AutoModelForMaskedLM, AutoTokenizer, PreTrainedModel, PreTrainedTokenizerBase File "", line 1412, in _handle_fromlist File "/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py", line 1136, in getattr module = self._get_module(self._class_to_module[name]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py", line 1148, in _get_module raise RuntimeError( RuntimeError: Failed to import transformers.models.auto because of the following error (look up to see its traceback): module 'sentencepiece._sentencepiece' has no attribute 'delete_ImmutableSentencePieceText_ImmutableSentencePiece' Colab paid products - Cancel contracts here

✌️❤️ Before starting Stable Diffusion WebUI (A1111), copy and run the following commands:

!pip uninstall -y sentencepiece transformers !pip install sentencepiece==0.2.0 !pip install transformers==4.41.2

After running these commands, start Stable Diffusion WebUI normally.

This fixed the issue for me on Google Colab. Hope it helps others.

MahdiMB92 IR Iran

Source: TheLastBen/fast-stable-diffusion