Beginner: Unable to run fastbook locally

Hello All,

I am on WSL/Ubuntu. Installed Jupyter, fastbook.
On the very first code cell, I get the following error. Need help in resolution


AttributeError Traceback (most recent call last)
Cell In[1], line 3
1 #hide
2 get_ipython().system(’ [ -e /content ] && pip install -Uqq fastbook’)
----> 3 import fastbook
4 fastbook.setup_book()

File ~/miniforge3/lib/python3.10/site-packages/fastbook/init.py:3
1 version = “0.0.28”
2 import matplotlib as mpl, pkgutil, requests, time
----> 3 from fastai.vision.all import *
4 from fastdownload import download_url
5 from pandas.api.types import CategoricalDtype

File ~/miniforge3/lib/python3.10/site-packages/fastai/vision/all.py:1
----> 1 from . import models
2 from …basics import *
3 from …callback.all import *

File ~/miniforge3/lib/python3.10/site-packages/fastai/vision/models/init.py:1
----> 1 from . import xresnet
2 from . import unet
3 from .tvm import *

File ~/miniforge3/lib/python3.10/site-packages/fastai/vision/models/xresnet.py:6
4 from future import annotations
5 from …torch_basics import *
----> 6 try: from torchvision.models.utils import load_state_dict_from_url
7 except ModuleNotFoundError: from torch.hub import load_state_dict_from_url
9 # %% auto 0

File ~/miniforge3/lib/python3.10/site-packages/torchvision/init.py:6
3 from modulefinder import Module
5 import torch
----> 6 from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
8 from .extension import _HAS_OPS
10 try:

File ~/miniforge3/lib/python3.10/site-packages/torchvision/models/init.py:2
1 from .alexnet import *
----> 2 from .convnext import *
3 from .densenet import *
4 from .efficientnet import *

File ~/miniforge3/lib/python3.10/site-packages/torchvision/models/convnext.py:8
5 from torch import nn, Tensor
6 from torch.nn import functional as F
----> 8 from …ops.misc import Conv2dNormActivation, Permute
9 from …ops.stochastic_depth import StochasticDepth
10 from …transforms._presets import ImageClassification

File ~/miniforge3/lib/python3.10/site-packages/torchvision/ops/init.py:1
----> 1 from ._register_onnx_ops import _register_custom_op
2 from .boxes import (
3 batched_nms,
4 box_area,
(…)
13 remove_small_boxes,
14 )
15 from .ciou_loss import complete_box_iou_loss

File ~/miniforge3/lib/python3.10/site-packages/torchvision/ops/_register_onnx_ops.py:5
2 import warnings
4 import torch
----> 5 from torch.onnx import symbolic_opset11 as opset11
6 from torch.onnx.symbolic_helper import parse_args
8 _ONNX_OPSET_VERSION_11 = 11

File ~/miniforge3/lib/python3.10/site-packages/torch/onnx/init.py:46
33 from .errors import CheckerError # Backwards compatibility
34 from .utils import (
35 _optimize_graph,
36 _run_symbolic_function,
(…)
43 unregister_custom_op_symbolic,
44 )
—> 46 from ._internal.exporter import ( # usort:skip. needs to be last to avoid circular import
47 DiagnosticOptions,
48 ExportOptions,
49 ONNXProgram,
50 ONNXProgramSerializer,
51 ONNXRuntimeOptions,
52 InvalidExportOptionsError,
53 OnnxExporterError,
54 OnnxRegistry,
55 dynamo_export,
56 enable_fake_mode,
57 )
59 from ._internal.onnxruntime import (
60 is_onnxrt_backend_supported,
61 OrtBackend as _OrtBackend,
62 OrtBackendOptions as _OrtBackendOptions,
63 OrtExecutionProvider as _OrtExecutionProvider,
64 )
66 all = [
67 # Modules
68 “symbolic_helper”,
(…)
114 “is_onnxrt_backend_supported”,
115 ]

File ~/miniforge3/lib/python3.10/site-packages/torch/onnx/_internal/exporter.py:44
42 from torch.onnx._internal import _beartype, io_adapter
43 from torch.onnx._internal.diagnostics import infra
—> 44 from torch.onnx._internal.fx import (
45 decomposition_table,
46 patcher as patcher,
47 registration,
48 serialization as fx_serialization,
49 )
51 # We can only import onnx from this module in a type-checking context to ensure that
52 # ‘import torch.onnx’ continues to work without having ‘onnx’ installed. We fully
53 # ‘import onnx’ inside of dynamo_export (by way of _assert_dependencies).
54 if TYPE_CHECKING:

File ~/miniforge3/lib/python3.10/site-packages/torch/onnx/_internal/fx/init.py:1
----> 1 from .patcher import ONNXTorchPatcher
2 from .serialization import save_model_with_external_data
5 all = [
6 “save_model_with_external_data”,
7 “ONNXTorchPatcher”,
8 ]

File ~/miniforge3/lib/python3.10/site-packages/torch/onnx/_internal/fx/patcher.py:11
8 try:
9 # safetensors is not an exporter requirement, but needed for some huggingface models
10 import safetensors # type: ignore[import] # noqa: F401
—> 11 import transformers # type: ignore[import]
12 from safetensors import torch as safetensors_torch # noqa: F401
14 has_safetensors_and_transformers = True

File ~/miniforge3/lib/python3.10/site-packages/transformers/init.py:26
23 from typing import TYPE_CHECKING
25 # Check the dependencies satisfy the minimal versions required.
—> 26 from . import dependency_versions_check
27 from .utils import (
28 OptionalDependencyNotAvailable,
29 _LazyModule,
(…)
47 logging,
48 )
51 logger = logging.get_logger(name) # pylint: disable=invalid-name

File ~/miniforge3/lib/python3.10/site-packages/transformers/dependency_versions_check.py:16
1 # Copyright 2020 The HuggingFace Team. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the “License”);
(…)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from .dependency_versions_table import deps
—> 16 from .utils.versions import require_version, require_version_core
19 # define which module versions we always want to check at run time
20 # (usually the ones defined in install_requires in setup.py)
21 #
22 # order specific notes:
23 # - tqdm must be checked before tokenizers
25 pkgs_to_check_at_runtime = [
26 “python”,
27 “tqdm”,
(…)
37 “pyyaml”,
38 ]

File ~/miniforge3/lib/python3.10/site-packages/transformers/utils/init.py:63
25 from .doc import (
26 add_code_sample_docstrings,
27 add_end_docstrings,
(…)
31 replace_return_docstrings,
32 )
33 from .generic import (
34 ContextManagers,
35 ExplicitEnum,
(…)
61 working_or_temp_dir,
62 )
—> 63 from .hub import (
64 CLOUDFRONT_DISTRIB_PREFIX,
65 HF_MODULES_CACHE,
66 HUGGINGFACE_CO_PREFIX,
67 HUGGINGFACE_CO_RESOLVE_ENDPOINT,
68 PYTORCH_PRETRAINED_BERT_CACHE,
69 PYTORCH_TRANSFORMERS_CACHE,
70 S3_BUCKET_PREFIX,
71 TRANSFORMERS_CACHE,
72 TRANSFORMERS_DYNAMIC_MODULE_NAME,
73 EntryNotFoundError,
74 PushInProgress,
75 PushToHubMixin,
76 RepositoryNotFoundError,
77 RevisionNotFoundError,
78 cached_file,
79 default_cache_path,
80 define_sagemaker_information,
81 download_url,
82 extract_commit_hash,
83 get_cached_models,
84 get_file_from_repo,
85 has_file,
86 http_user_agent,
87 is_offline_mode,
88 is_remote_url,
89 move_cache,
90 send_example_telemetry,
91 try_to_load_from_cache,
92 )
93 from .import_utils import (
94 ACCELERATE_MIN_VERSION,
95 ENV_VARS_TRUE_AND_AUTO_VALUES,
(…)
200 torch_only_method,
201 )
202 from .peft_utils import (
203 ADAPTER_CONFIG_NAME,
204 ADAPTER_SAFE_WEIGHTS_NAME,
(…)
207 find_adapter_config_file,
208 )

File ~/miniforge3/lib/python3.10/site-packages/transformers/utils/hub.py:96
86 old_default_cache_path = os.path.join(torch_cache_home, “transformers”)
88 # Determine default cache directory. Lots of legacy environment variables to ensure backward compatibility.
89 # The best way to set the cache path is with the environment variable HF_HOME. For more details, checkout this
90 # documentation page: Environment variables.
(…)
94 #
95 # TODO: clean this for v5?
—> 96 PYTORCH_PRETRAINED_BERT_CACHE = os.getenv(“PYTORCH_PRETRAINED_BERT_CACHE”, constants.HF_HUB_CACHE)
97 PYTORCH_TRANSFORMERS_CACHE = os.getenv(“PYTORCH_TRANSFORMERS_CACHE”, PYTORCH_PRETRAINED_BERT_CACHE)
98 TRANSFORMERS_CACHE = os.getenv(“TRANSFORMERS_CACHE”, PYTORCH_TRANSFORMERS_CACHE)

AttributeError: module ‘huggingface_hub.constants’ has no attribute ‘HF_HUB_CACHE’