{"slug": "chapter-1-questions", "title": "Chapter 1 questions", "summary": "A user encountered an AttributeError when running a sentiment analysis pipeline in a Colab notebook, likely due to a version incompatibility between transformers and torchvision. The error trace shows a failed import chain from transformers to torchvision's roi_align module, suggesting a need to update or reinstall dependencies.", "body_md": "When I use the Colab notebook, I get an error on the second cell. Does anyone know how to fix it?\n\nfrom transformers import pipeline\n\nclassifier = pipeline(“sentiment-analysis”)\n\nclassifier(“I’ve been waiting for a HuggingFace course my whole life.”)\n\n---------------------------------------------------------------------------\n\nAttributeError Traceback (most recent call last)\n\n/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _*getattr*_(self, name)\n\n2248 try:\n\n→ 2249 module = self._get_module(self._class_to_module[name])\n\n2250 value = getattr(module, name)\n\n/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name)\n\n2482 except Exception as e:\n\n→ 2483 raise e\n\n2484\n\n/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _get_module(self, module_name)\n\n2480 try:\n\n→ 2481 return importlib.import_module(“.” + module_name, self._*name*_)\n\n2482 except Exception as e:\n\n/usr/lib/python3.12/importlib/_*init*_.py in import_module(name, package)\n\n89 level += 1\n\n—> 90 return _bootstrap._gcd_import(name[level:], package, level)\n\n91\n\n/usr/lib/python3.12/importlib/_bootstrap.py in _gcd_import(name, package, level)\n\n/usr/lib/python3.12/importlib/_bootstrap.py in _find_and_load(name, import_)\n\n/usr/lib/python3.12/importlib/_bootstrap.py in _find_and_load_unlocked(name, import_)\n\n/usr/lib/python3.12/importlib/_bootstrap.py in _load_unlocked(spec)\n\n/usr/lib/python3.12/importlib/_bootstrap_external.py in exec_module(self, module)\n\n/usr/lib/python3.12/importlib/_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)\n\n/usr/local/lib/python3.12/dist-packages/transformers/pipelines/_*init*_.py in\n\n26 from ..feature_extraction_utils import FeatureExtractionMixin\n\n—> 27 from ..image_processing_utils import BaseImageProcessor\n\n28 from ..models.auto.configuration_auto import AutoConfig\n\n/usr/local/lib/python3.12/dist-packages/transformers/image_processing_utils.py in\n\n33 )\n\n—> 34 from .processing_utils import ImagesKwargs, Unpack\n\n35 from .utils import (\n\n/usr/local/lib/python3.12/dist-packages/transformers/processing_utils.py in\n\n62 from .utils.chat_template_utils import _get_template_variables, render_jinja_template\n\n—> 63 from .utils.type_validators import (\n\n64 device_validator,\n\n/usr/local/lib/python3.12/dist-packages/transformers/utils/type_validators.py in\n\n7 from ..tokenization_utils_base import PaddingStrategy, TruncationStrategy\n\n----> 8 from ..video_utils import VideoMetadataType\n\n9 from .generic import TensorType\n\n/usr/local/lib/python3.12/dist-packages/transformers/video_utils.py in\n\n48 if is_torchvision_available():\n\n—> 49 from torchvision import io as torchvision_io\n\n50\n\n/usr/local/lib/python3.12/dist-packages/torchvision/_*init*_.py in\n\n7 from . import extension # usort:skip # noqa: F401\n\n----> 8 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils # usort:skip\n\n9\n\n/usr/local/lib/python3.12/dist-packages/torchvision/models/_*init*_.py in\n\n1 from .alexnet import *\n\n----> 2 from .convnext import *\n\n3 from .densenet import *\n\n/usr/local/lib/python3.12/dist-packages/torchvision/models/convnext.py in\n\n9 from ..ops.misc import Conv2dNormActivation, Permute\n\n—> 10 from ..ops.stochastic_depth import StochasticDepth\n\n11 from ..transforms._presets import ImageClassification\n\n/usr/local/lib/python3.12/dist-packages/torchvision/ops/_*init*_.py in\n\n22 from .misc import Conv2dNormActivation, Conv3dNormActivation, FrozenBatchNorm2d, MLP, Permute, SqueezeExcitation\n\n—> 23 from .poolers import MultiScaleRoIAlign\n\n24 from .ps_roi_align import ps_roi_align, PSRoIAlign\n\n/usr/local/lib/python3.12/dist-packages/torchvision/ops/poolers.py in\n\n9 from ..utils import _log_api_usage_once\n\n—> 10 from .roi_align import roi_align\n\n11\n\n/usr/local/lib/python3.12/dist-packages/torchvision/ops/roi_align.py in\n\n6 from torch import nn, Tensor\n\n----> 7 from torch._dynamo.utils import is_compile_supported\n\n8 from torch.jit.annotations import BroadcastingList2\n\n/usr/local/lib/python3.12/dist-packages/torch/_dynamo/_*init*_.py in\n\n12\n\n—> 13 from . import (\n\n14 aot_compile,\n\n/usr/local/lib/python3.12/dist-packages/torch/_dynamo/aot_compile.py in\n\n14 import torch.fx\n\n—> 15 from torch._dynamo.convert_frame import GraphRuntimeEnv\n\n16 from torch._dynamo.graph_utils import _graph_device_type\n\n/usr/local/lib/python3.12/dist-packages/torch/_dynamo/convert_frame.py in\n\n61 from torch._dynamo.distributed import get_compile_pg\n\n—> 62 from torch._dynamo.symbolic_convert import TensorifyState\n\n63 from torch._guards import compile_context, CompileContext, CompileId, tracing\n\n/usr/local/lib/python3.12/dist-packages/torch/_dynamo/symbolic_convert.py in\n\n53 from torch._dynamo.dynamo_profiler import DynamoProfilerState, FunctionTraceTiming\n\n—> 54 from torch._dynamo.exc import ObservedException, TensorifyScalarRestartAnalysis\n\n55 from torch._guards import InlinedCodeCache, tracing, TracingContext\n\n/usr/local/lib/python3.12/dist-packages/torch/_dynamo/exc.py in\n\n43 from . import config\n\n—> 44 from .utils import counters\n\n45\n\n/usr/local/lib/python3.12/dist-packages/torch/_dynamo/utils.py in\n\n69 import torch._functorch.config\n\n—> 70 import torch.fx.experimental.symbolic_shapes\n\n71 import torch.utils._pytree as pytree\n\n/usr/local/lib/python3.12/dist-packages/torch/fx/experimental/symbolic_shapes.py in\n\n79 from torch.utils._python_dispatch import is_traceable_wrapper_subclass\n\n—> 80 from torch.utils._sympy.functions import (\n\n81 Application,\n\n/usr/local/lib/python3.12/dist-packages/torch/utils/_sympy/functions.py in\n\n187 # not, this can potentially cause correctness issues.\n\n→ 188 class FloorDiv(sympy.Function):\n\n189 “”\"\n\n/usr/local/lib/python3.12/dist-packages/torch/utils/_sympy/functions.py in FloorDiv()\n\n210\n\n→ 211 def _sympystr(self, printer: sympy.printing.StrPrinter) → str:\n\n212 base = printer.parenthesize(self.base, PRECEDENCE[“Atom”] - 0.5)\n\nAttributeError: module ‘sympy’ has no attribute ‘printing’\n\nThe above exception was the direct cause of the following exception:\n\nModuleNotFoundError Traceback (most recent call last)\n\n/tmp/ipykernel_3167/711506748.py in <cell line: 0>()\n\n----> 1 from transformers import pipeline\n\n2\n\n3 classifier = pipeline(“sentiment-analysis”)\n\n4 classifier(“I’ve been waiting for a HuggingFace course my whole life.”)\n\n/usr/local/lib/python3.12/dist-packages/transformers/utils/import_utils.py in _*getattr*_(self, name)\n\n2335 ) from e\n\n2336 else:\n\n→ 2337 raise ModuleNotFoundError(\n\n2338 f\"Could not import module ‘{name}’. Are this object’s requirements defined correctly?\"\n\n2339 ) from e\n\nModuleNotFoundError: Could not import module ‘pipeline’. Are this object’s requirements defined correctly?", "url": "https://wpnews.pro/news/chapter-1-questions", "canonical_source": "https://discuss.huggingface.co/t/chapter-1-questions/6797?page=6#post_125", "published_at": "2026-07-07 16:43:25+00:00", "updated_at": "2026-07-07 17:10:48.903299+00:00", "lang": "en", "topics": ["artificial-intelligence", "natural-language-processing", "developer-tools"], "entities": ["Hugging Face", "Colab", "transformers", "torchvision", "PyTorch"], "alternates": {"html": "https://wpnews.pro/news/chapter-1-questions", "markdown": "https://wpnews.pro/news/chapter-1-questions.md", "text": "https://wpnews.pro/news/chapter-1-questions.txt", "jsonld": "https://wpnews.pro/news/chapter-1-questions.jsonld"}}