Skip to content

[Bug]: Anomalib installation with missing dependencies #2449

@Paucaster3

Description

@Paucaster3

Describe the bug

Description

After installing anomalib with

pip install anomalib

Several dependencies produce ModuleNotFoundError exceptions.

Then, i run the command

anomalib doctor

as suggested in this comment, obtaining the next indications:

anomalib doctor
To use other subcommand using `anomalib install`
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/bin/anomalib:5 in <module>   │
│                                                                                                  │
│   2 # -*- coding: utf-8 -*-                                                                      │
│   3 import re                                                                                    │
│   4 import sys                                                                                   │
│ ❱ 5 from anomalib.cli.cli import main                                                            │
│   6 if __name__ == '__main__':                                                                   │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│   8 │   sys.exit(main())                                                                         │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/cli/__init__.py:6 in <module>                                                          │
│                                                                                                  │
│   3 # Copyright (C) 2022 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .cli import AnomalibCLI                                                                 │
│   7                                                                                              │
│   8 __all__ = ["AnomalibCLI"]                                                                    │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/cli/cli.py:18 in <module>                                                              │
│                                                                                                  │
│    15 from rich import traceback                                                                 │
│    16                                                                                            │
│    17 from anomalib import TaskType, __version__                                                 │
│ ❱  18 from anomalib.cli.pipelines import PIPELINE_REGISTRY, pipeline_subcommands, run_pipeline   │
│    19 from anomalib.cli.utils.help_formatter import CustomHelpFormatter, get_short_docstring     │
│    20 from anomalib.cli.utils.openvino import add_openvino_export_arguments                      │
│    21 from anomalib.loggers import configure_logger                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/cli/pipelines.py:16 in <module>                                                        │
│                                                                                                  │
│   13 logger = logging.getLogger(__name__)                                                        │
│   14                                                                                             │
│   15 if package_available("anomalib.pipelines"):                                                 │
│ ❱ 16 │   from anomalib.pipelines import Benchmark                                                │
│   17 │   from anomalib.pipelines.components.base import Pipeline                                 │
│   18 │                                                                                           │
│   19 │   PIPELINE_REGISTRY: dict[str, type[Pipeline]] | None = {"benchmark": Benchmark}          │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/__init__.py:6 in <module>                                                    │
│                                                                                                  │
│   3 # Copyright (C) 2024 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .benchmark import Benchmark                                                             │
│   7                                                                                              │
│   8 __all__ = ["Benchmark"]                                                                      │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/benchmark/__init__.py:6 in <module>                                          │
│                                                                                                  │
│   3 # Copyright (C) 2024 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .pipeline import Benchmark                                                              │
│   7                                                                                              │
│   8 __all__ = ["Benchmark"]                                                                      │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/benchmark/pipeline.py:11 in <module>                                         │
│                                                                                                  │
│    8 from anomalib.pipelines.components.base import Pipeline, Runner                             │
│    9 from anomalib.pipelines.components.runners import ParallelRunner, SerialRunner              │
│   10                                                                                             │
│ ❱ 11 from .generator import BenchmarkJobGenerator                                                │
│   12                                                                                             │
│   13                                                                                             │
│   14 class Benchmark(Pipeline):                                                                  │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/benchmark/generator.py:9 in <module>                                         │
│                                                                                                  │
│    6 from collections.abc import Generator                                                       │
│    7                                                                                             │
│    8 from anomalib.data import get_datamodule                                                    │
│ ❱  9 from anomalib.models import get_model                                                       │
│   10 from anomalib.pipelines.components import JobGenerator                                      │
│   11 from anomalib.pipelines.components.utils import get_iterator_from_grid_dict                 │
│   12 from anomalib.pipelines.types import PREV_STAGE_RESULT                                      │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/__init__.py:15 in <module>                                                      │
│                                                                                                  │
│    12 from anomalib.models.components import AnomalyModule                                       │
│    13 from anomalib.utils.path import convert_to_snake_case                                      │
│    14                                                                                            │
│ ❱  15 from .image import (                                                                       │
│    16 │   Cfa,                                                                                   │
│    17 │   Cflow,                                                                                 │
│    18 │   Csflow,                                                                                │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/__init__.py:23 in <module>                                                │
│                                                                                                  │
│   20 from .rkde import Rkde                                                                      │
│   21 from .stfpm import Stfpm                                                                    │
│   22 from .uflow import Uflow                                                                    │
│ ❱ 23 from .vlm_ad import VlmAd                                                                   │
│   24 from .winclip import WinClip                                                                │
│   25                                                                                             │
│   26 __all__ = [                                                                                 │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/__init__.py:6 in <module>                                          │
│                                                                                                  │
│   3 # Copyright (C) 2024 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .lightning_model import VlmAd                                                           │
│   7                                                                                              │
│   8 __all__ = ["VlmAd"]                                                                          │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/lightning_model.py:14 in <module>                                  │
│                                                                                                  │
│    11 from anomalib import LearningType                                                          │
│    12 from anomalib.models import AnomalyModule                                                  │
│    13                                                                                            │
│ ❱  14 from .backends import Backend, ChatGPT, Huggingface, Ollama                                │
│    15 from .utils import ModelName, Prompt                                                       │
│    16                                                                                            │
│    17 logger = logging.getLogger(__name__)                                                       │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/backends/__init__.py:7 in <module>                                 │
│                                                                                                  │
│    4 # SPDX-License-Identifier: Apache-2.0                                                       │
│    5                                                                                             │
│    6 from .base import Backend                                                                   │
│ ❱  7 from .chat_gpt import ChatGPT                                                               │
│    8 from .huggingface import Huggingface                                                        │
│    9 from .ollama import Ollama                                                                  │
│   10                                                                                             │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/backends/chat_gpt.py:12 in <module>                                │
│                                                                                                  │
│     9 from pathlib import Path                                                                   │
│    10 from typing import TYPE_CHECKING                                                           │
│    11                                                                                            │
│ ❱  12 from dotenv import load_dotenv                                                             │
│    13 from lightning_utilities.core.imports import package_available                             │
│    14                                                                                            │
│    15 from anomalib.models.image.vlm_ad.utils import Prompt      

Is there anything I am missing?

Thank you.

Dataset

Other (please specify in the text field below)

Model

PatchCore

Steps to reproduce the behavior

  1. Install anomalib
pip install anomalib
  1. Python code used
from anomalib import TaskType
from anomalib.data import Folder
from anomalib.data.utils import TestSplitMode
from anomalib.models import Patchcore
from anomalib.engine import Engine

datamodule = Folder(
       name=dataset_name,
       normal_dir=selected_normal_path,
       test_split_mode=TestSplitMode.SYNTHETIC,
       task=TaskType.SEGMENTATION,
)

datamodule.setup()

model = Patchcore()
engine = Engine(task=TaskType.SEGMENTATION)

engine.train(datamodule=datamodule, model=model)

OS information

OS information:

  • OS: Ubuntu 20.04
  • Python version: 3.11.10
  • Anomalib version: 1.2.0
  • PyTorch version: 2.5.1

Expected behavior

Anomalib loads all libraries and starts training.

Screenshots

No response

Pip/GitHub

pip

What version/branch did you use?

22.02

Configuration YAML

No configuration YAML

Logs

When running anomalib doctor or anomalib install:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/bin/anomalib:5 in <module>   │
│                                                                                                  │
│   2 # -*- coding: utf-8 -*-                                                                      │
│   3 import re                                                                                    │
│   4 import sys                                                                                   │
│ ❱ 5 from anomalib.cli.cli import main                                                            │
│   6 if __name__ == '__main__':                                                                   │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│   8 │   sys.exit(main())                                                                         │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/cli/__init__.py:6 in <module>                                                          │
│                                                                                                  │
│   3 # Copyright (C) 2022 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .cli import AnomalibCLI                                                                 │
│   7                                                                                              │
│   8 __all__ = ["AnomalibCLI"]                                                                    │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/cli/cli.py:18 in <module>                                                              │
│                                                                                                  │
│    15 from rich import traceback                                                                 │
│    16                                                                                            │
│    17 from anomalib import TaskType, __version__                                                 │
│ ❱  18 from anomalib.cli.pipelines import PIPELINE_REGISTRY, pipeline_subcommands, run_pipeline   │
│    19 from anomalib.cli.utils.help_formatter import CustomHelpFormatter, get_short_docstring     │
│    20 from anomalib.cli.utils.openvino import add_openvino_export_arguments                      │
│    21 from anomalib.loggers import configure_logger                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/cli/pipelines.py:16 in <module>                                                        │
│                                                                                                  │
│   13 logger = logging.getLogger(__name__)                                                        │
│   14                                                                                             │
│   15 if package_available("anomalib.pipelines"):                                                 │
│ ❱ 16 │   from anomalib.pipelines import Benchmark                                                │
│   17 │   from anomalib.pipelines.components.base import Pipeline                                 │
│   18 │                                                                                           │
│   19 │   PIPELINE_REGISTRY: dict[str, type[Pipeline]] | None = {"benchmark": Benchmark}          │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/__init__.py:6 in <module>                                                    │
│                                                                                                  │
│   3 # Copyright (C) 2024 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .benchmark import Benchmark                                                             │
│   7                                                                                              │
│   8 __all__ = ["Benchmark"]                                                                      │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/benchmark/__init__.py:6 in <module>                                          │
│                                                                                                  │
│   3 # Copyright (C) 2024 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .pipeline import Benchmark                                                              │
│   7                                                                                              │
│   8 __all__ = ["Benchmark"]                                                                      │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/benchmark/pipeline.py:11 in <module>                                         │
│                                                                                                  │
│    8 from anomalib.pipelines.components.base import Pipeline, Runner                             │
│    9 from anomalib.pipelines.components.runners import ParallelRunner, SerialRunner              │
│   10                                                                                             │
│ ❱ 11 from .generator import BenchmarkJobGenerator                                                │
│   12                                                                                             │
│   13                                                                                             │
│   14 class Benchmark(Pipeline):                                                                  │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/pipelines/benchmark/generator.py:9 in <module>                                         │
│                                                                                                  │
│    6 from collections.abc import Generator                                                       │
│    7                                                                                             │
│    8 from anomalib.data import get_datamodule                                                    │
│ ❱  9 from anomalib.models import get_model                                                       │
│   10 from anomalib.pipelines.components import JobGenerator                                      │
│   11 from anomalib.pipelines.components.utils import get_iterator_from_grid_dict                 │
│   12 from anomalib.pipelines.types import PREV_STAGE_RESULT                                      │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/__init__.py:15 in <module>                                                      │
│                                                                                                  │
│    12 from anomalib.models.components import AnomalyModule                                       │
│    13 from anomalib.utils.path import convert_to_snake_case                                      │
│    14                                                                                            │
│ ❱  15 from .image import (                                                                       │
│    16 │   Cfa,                                                                                   │
│    17 │   Cflow,                                                                                 │
│    18 │   Csflow,                                                                                │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/__init__.py:23 in <module>                                                │
│                                                                                                  │
│   20 from .rkde import Rkde                                                                      │
│   21 from .stfpm import Stfpm                                                                    │
│   22 from .uflow import Uflow                                                                    │
│ ❱ 23 from .vlm_ad import VlmAd                                                                   │
│   24 from .winclip import WinClip                                                                │
│   25                                                                                             │
│   26 __all__ = [                                                                                 │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/__init__.py:6 in <module>                                          │
│                                                                                                  │
│   3 # Copyright (C) 2024 Intel Corporation                                                       │
│   4 # SPDX-License-Identifier: Apache-2.0                                                        │
│   5                                                                                              │
│ ❱ 6 from .lightning_model import VlmAd                                                           │
│   7                                                                                              │
│   8 __all__ = ["VlmAd"]                                                                          │
│   9                                                                                              │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/lightning_model.py:14 in <module>                                  │
│                                                                                                  │
│    11 from anomalib import LearningType                                                          │
│    12 from anomalib.models import AnomalyModule                                                  │
│    13                                                                                            │
│ ❱  14 from .backends import Backend, ChatGPT, Huggingface, Ollama                                │
│    15 from .utils import ModelName, Prompt                                                       │
│    16                                                                                            │
│    17 logger = logging.getLogger(__name__)                                                       │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/backends/__init__.py:7 in <module>                                 │
│                                                                                                  │
│    4 # SPDX-License-Identifier: Apache-2.0                                                       │
│    5                                                                                             │
│    6 from .base import Backend                                                                   │
│ ❱  7 from .chat_gpt import ChatGPT                                                               │
│    8 from .huggingface import Huggingface                                                        │
│    9 from .ollama import Ollama                                                                  │
│   10                                                                                             │
│                                                                                                  │
│ /home/serverai/repo/damages_detection/va-270-damages-detection/venv/lib/python3.11/site-packages │
│ /anomalib/models/image/vlm_ad/backends/chat_gpt.py:12 in <module>                                │
│                                                                                                  │
│     9 from pathlib import Path                                                                   │
│    10 from typing import TYPE_CHECKING                                                           │
│    11                                                                                            │
│ ❱  12 from dotenv import load_dotenv                                                             │
│    13 from lightning_utilities.core.imports import package_available                             │
│    14                                                                                            │
│    15 from anomalib.models.image.vlm_ad.utils import Prompt                                      │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

When trying to run the script it starts throwing each ModuleNotFoundError.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions