Week 1 practice lab: Installation of packages is not working

I couldn’t tag week 1 for some reason
I have been retrying installing the packages and also waited a portion of time to see if it needed time to finish downloading. Here is the code and output on my end:


WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Requirement already satisfied: pip in /opt/conda/lib/python3.12/site-packages (25.1.1)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Requirement already satisfied: tensorflow==2.18.0 in /opt/conda/lib/python3.12/site-packages (2.18.0)
Requirement already satisfied: keras==3.9.0 in /opt/conda/lib/python3.12/site-packages (3.9.0)
Requirement already satisfied: absl-py>=1.0.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (2.2.0)
Requirement already satisfied: astunparse>=1.6.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.6.3)
Requirement already satisfied: flatbuffers>=24.3.25 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (25.2.10)
Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (0.6.0)
Requirement already satisfied: google-pasta>=0.1.1 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (0.2.0)
Requirement already satisfied: opt-einsum>=2.3.2 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (3.4.0)
Requirement already satisfied: packaging in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (24.2)
Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.3 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (5.28.3)
Requirement already satisfied: requests<3,>=2.21.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (2.32.3)
Requirement already satisfied: setuptools in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (80.1.0)
Requirement already satisfied: six>=1.12.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.17.0)
Requirement already satisfied: termcolor>=1.1.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (3.1.0)
Requirement already satisfied: typing-extensions>=3.6.6 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (4.13.2)
Requirement already satisfied: wrapt>=1.11.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.17.2)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.67.1)
Requirement already satisfied: tensorboard<2.19,>=2.18 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (2.18.0)
Requirement already satisfied: h5py>=3.11.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (3.13.0)
Requirement already satisfied: ml-dtypes<0.5.0,>=0.4.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (0.4.0)
Requirement already satisfied: numpy in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (1.26.4)
Requirement already satisfied: rich in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (14.0.0)
Requirement already satisfied: namex in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (0.0.9)
Requirement already satisfied: optree in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (0.15.0)
Requirement already satisfied: charset_normalizer<4,>=2 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (3.4.2)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (1.26.19)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (2025.4.26)
Requirement already satisfied: markdown>=2.6.8 in /opt/conda/lib/python3.12/site-packages (from tensorboard<2.19,>=2.18->tensorflow==2.18.0) (3.8)
Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /opt/conda/lib/python3.12/site-packages (from tensorboard<2.19,>=2.18->tensorflow==2.18.0) (0.7.0)
Requirement already satisfied: werkzeug>=1.0.1 in /opt/conda/lib/python3.12/site-packages (from tensorboard<2.19,>=2.18->tensorflow==2.18.0) (3.1.3)
Requirement already satisfied: MarkupSafe>=2.1.1 in /opt/conda/lib/python3.12/site-packages (from werkzeug>=1.0.1->tensorboard<2.19,>=2.18->tensorflow==2.18.0) (3.0.2)
Requirement already satisfied: markdown-it-py>=2.2.0 in /opt/conda/lib/python3.12/site-packages (from rich->keras==3.9.0) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /opt/conda/lib/python3.12/site-packages (from rich->keras==3.9.0) (2.19.1)
Requirement already satisfied: mdurl~=0.1 in /opt/conda/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich->keras==3.9.0) (0.1.2)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.
And then when I run this:
from datasets import load_dataset
from transformers import AutoModelForSeq2SeqLM
from transformers import AutoTokenizer
from transformers import GenerationConfig
I see: ModuleNotFoundError: No module named ‘torch._C’ when importing the libraries

1 Like

Dear @Aksgem,

Welcome to the community!

Please try restoring the lab files first, and then restart the kernel to ensure all dependencies are properly loaded.

Hi @Girijesh,

Thank you for the welcome and the fast reply!

I redownloaded the lab files and restarted the kernel and ended up with same result of module not found and the same output on both cells.

1 Like

Dear @Aksgem,

Are you working on your local environment or coursera platform?

@Girijesh
I am working from the AWS platform from the lab account from coursera.

1 Like

Dear @Aksgem,

Please follow this link GenAI with LLMs Lab FAQ
and let me know the status.

I’m also facing the Same issue while installing : # First upgrade pip
%pip install --upgrade pip

Install tensorflow and keras first

%pip install tensorflow==2.18.0 keras==3.9.0

Install torch and torchdata

%pip install --no-deps torch==2.5.1 torchdata==0.6.0 --quiet

Then install other packages except TRL

%pip install -U
datasets==2.17.0
transformers==4.38.2
evaluate==0.4.0
rouge_score==0.1.2
peft==0.3.0 --quiet
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Requirement already satisfied: pip in /opt/conda/lib/python3.12/site-packages (25.1.1)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Requirement already satisfied: tensorflow==2.18.0 in /opt/conda/lib/python3.12/site-packages (2.18.0)
Requirement already satisfied: keras==3.9.0 in /opt/conda/lib/python3.12/site-packages (3.9.0)
Requirement already satisfied: absl-py>=1.0.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (2.2.0)
Requirement already satisfied: astunparse>=1.6.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.6.3)
Requirement already satisfied: flatbuffers>=24.3.25 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (25.2.10)
Requirement already satisfied: gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (0.6.0)
Requirement already satisfied: google-pasta>=0.1.1 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (0.2.0)
Requirement already satisfied: opt-einsum>=2.3.2 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (3.4.0)
Requirement already satisfied: packaging in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (24.2)
Requirement already satisfied: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<6.0.0dev,>=3.20.3 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (5.28.3)
Requirement already satisfied: requests<3,>=2.21.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (2.32.3)
Requirement already satisfied: setuptools in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (80.1.0)
Requirement already satisfied: six>=1.12.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.17.0)
Requirement already satisfied: termcolor>=1.1.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (3.1.0)
Requirement already satisfied: typing-extensions>=3.6.6 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (4.13.2)
Requirement already satisfied: wrapt>=1.11.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.17.2)
Requirement already satisfied: grpcio<2.0,>=1.24.3 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (1.67.1)
Requirement already satisfied: tensorboard<2.19,>=2.18 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (2.18.0)
Requirement already satisfied: h5py>=3.11.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (3.13.0)
Requirement already satisfied: ml-dtypes<0.5.0,>=0.4.0 in /opt/conda/lib/python3.12/site-packages (from tensorflow==2.18.0) (0.4.0)
Requirement already satisfied: numpy in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (1.26.4)
Requirement already satisfied: rich in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (14.0.0)
Requirement already satisfied: namex in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (0.0.9)
Requirement already satisfied: optree in /opt/conda/lib/python3.12/site-packages (from keras==3.9.0) (0.15.0)
Requirement already satisfied: charset_normalizer<4,>=2 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (3.4.2)
Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (1.26.19)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.12/site-packages (from requests<3,>=2.21.0->tensorflow==2.18.0) (2025.4.26)
Requirement already satisfied: markdown>=2.6.8 in /opt/conda/lib/python3.12/site-packages (from tensorboard<2.19,>=2.18->tensorflow==2.18.0) (3.8)
Requirement already satisfied: tensorboard-data-server<0.8.0,>=0.7.0 in /opt/conda/lib/python3.12/site-packages (from tensorboard<2.19,>=2.18->tensorflow==2.18.0) (0.7.0)
Requirement already satisfied: werkzeug>=1.0.1 in /opt/conda/lib/python3.12/site-packages (from tensorboard<2.19,>=2.18->tensorflow==2.18.0) (3.1.3)
Requirement already satisfied: MarkupSafe>=2.1.1 in /opt/conda/lib/python3.12/site-packages (from werkzeug>=1.0.1->tensorboard<2.19,>=2.18->tensorflow==2.18.0) (3.0.2)
Requirement already satisfied: markdown-it-py>=2.2.0 in /opt/conda/lib/python3.12/site-packages (from rich->keras==3.9.0) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /opt/conda/lib/python3.12/site-packages (from rich->keras==3.9.0) (2.19.1)
Requirement already satisfied: mdurl~=0.1 in /opt/conda/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich->keras==3.9.0) (0.1.2)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
WARNING: Ignoring invalid distribution ~orch (/opt/conda/lib/python3.12/site-packages)
Note: you may need to restart the kernel to use updated packages.

1 Like

I ran the whole Lab and all the cells ran fine for me! I am not sure where you guys might be going wrong but I would suggest to delete the current file and reload the lab with the aws s3 cp --recursive s3://dlai-generative-ai/labs-202502/w1-549876/ ./

1 Like

It seems I did not wait long enough for the installation of the dependencies. Thank you for your help, @gent.spah and @Girijesh!

2 Likes

Dear @Boothalingam,

Welcome to the community!

Has your issue been resolved?

can anyone help me with this error

ModuleNotFoundError: No module named ‘torch._C’

======


ModuleNotFoundError Traceback (most recent call last)
Cell In[3], line 2
1 from datasets import load_dataset
----> 2 from transformers import AutoModelForSeq2SeqLM
3 from transformers import AutoTokenizer
4 from transformers import GenerationConfig

File /opt/conda/lib/python3.12/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 /opt/conda/lib/python3.12/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 /opt/conda/lib/python3.12/site-packages/transformers/utils/init.py:33
24 from .constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, IMAGENET_STANDARD_MEAN, IMAGENET_STANDARD_STD
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,
36 ModelOutput,
37 PaddingStrategy,
38 TensorType,
39 add_model_info_to_auto_map,
40 cached_property,
41 can_return_loss,
42 expand_dims,
43 find_labels,
44 flatten_dict,
45 infer_framework,
46 is_jax_tensor,
47 is_numpy_array,
48 is_tensor,
49 is_tf_symbolic_tensor,
50 is_tf_tensor,
51 is_torch_device,
52 is_torch_dtype,
53 is_torch_tensor,
54 reshape,
55 squeeze,
56 strtobool,
57 tensor_size,
58 to_numpy,
59 to_py_obj,
60 transpose,
61 working_or_temp_dir,
62 )
63 from .hub import (
64 CLOUDFRONT_DISTRIB_PREFIX,
65 HF_MODULES_CACHE,
(…)
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 )

File /opt/conda/lib/python3.12/site-packages/transformers/utils/generic.py:442
438 return tuple(self[k] for k in self.keys())
441 if is_torch_available():
→ 442 import torch.utils._pytree as _torch_pytree
444 def _model_output_flatten(output: ModelOutput) → Tuple[List[Any], “_torch_pytree.Context”]:
445 return list(output.values()), list(output.keys())

File /opt/conda/lib/python3.12/site-packages/torch/utils/init.py:8
5 import weakref
7 import torch
----> 8 from torch.utils import (
9 backcompat as backcompat,
10 collect_env as collect_env,
11 data as data,
12 deterministic as deterministic,
13 hooks as hooks,
14 )
15 from torch.utils.backend_registration import (
16 generate_methods_for_privateuse1_backend,
17 rename_privateuse1_backend,
18 )
19 from torch.utils.cpp_backtrace import get_cpp_backtrace

File /opt/conda/lib/python3.12/site-packages/torch/utils/backcompat/init.py:2
1 # mypy: allow-untyped-defs
----> 2 from torch._C import _set_backcompat_broadcast_warn
3 from torch._C import _get_backcompat_broadcast_warn
4 from torch._C import _set_backcompat_keepdim_warn

ModuleNotFoundError: No module named ‘torch._C’

I inserted a
import torch._C
cell before and that seems to have gotten me past this

1 Like

Dear @raoanils,
Welcome to the Community!

Please refer to this post by @chris.favila : GenAI with LLMs Lab FAQ
Kindly follow the steps outlined there - and you will able to resolve the issue.

If the problem persists after trying those steps, please feel free connect me.

I uninstalled the torch package and installed again. It works

1 Like

Dear @Boothalingam,

Sounds great.

Please feel free to post your questions or doubts under the appropriate category. However, kindly refrain from sharing code on this community platform.