anomalib: [Bug]: No module named 'lightning'

Describe the bug

I‘m running the " 001_getting_started.ipynb ",and in the “import” module ,I got error like this:

File ~/PycharmProjects/anomalib1/anomalib/src/anomalib/data/base/datamodule.py:11 8 from abc import ABC 9 from typing import TYPE_CHECKING, Any —> 11 from lightning.pytorch import LightningDataModule 12 from lightning.pytorch.utilities.types import EVAL_DATALOADERS, TRAIN_DATALOADERS 13 from torch.utils.data.dataloader import DataLoader, default_collate

ModuleNotFoundError: No module named ‘lightning’

Dataset

MVTec

Model

N/A

Steps to reproduce the behavior

non

OS information

OS information:

  • OS: mac m2 pro
  • Python version: 3.10.13
  • Anomalib version:1.0
  • PyTorch version: 2.2
  • run on pycharm

Expected behavior

please tell me how can I successfully run this notebook ,thanks.

Screenshots

non

Pip/GitHub

pip

What version/branch did you use?

main

Configuration YAML

non

Logs

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[6], line 9
      6 from torchvision.transforms import ToPILImage
      8 from anomalib import TaskType
----> 9 from anomalib.data import MVTec
     10 from anomalib.data.utils import read_image
     11 from anomalib.deploy import ExportType, OpenVINOInferencer

File ~/PycharmProjects/anomalib1/anomalib/src/anomalib/data/__init__.py:16
     12 from omegaconf import DictConfig, ListConfig
     14 from anomalib.utils.config import to_tuple
---> 16 from .base import AnomalibDataModule, AnomalibDataset
     17 from .depth import DepthDataFormat, Folder3D, MVTec3D
     18 from .image import BTech, Folder, ImageDataFormat, Kolektor, MVTec, Visa

File ~/PycharmProjects/anomalib1/anomalib/src/anomalib/data/base/__init__.py:7
      1 """Base classes for custom dataset and datamodules."""
      3 # Copyright (C) 2022 Intel Corporation
      4 # SPDX-License-Identifier: Apache-2.0
----> 7 from .datamodule import AnomalibDataModule
      8 from .dataset import AnomalibDataset
      9 from .depth import AnomalibDepthDataset

File ~/PycharmProjects/anomalib1/anomalib/src/anomalib/data/base/datamodule.py:11
      8 from abc import ABC
      9 from typing import TYPE_CHECKING, Any
---> 11 from lightning.pytorch import LightningDataModule
     12 from lightning.pytorch.utilities.types import EVAL_DATALOADERS, TRAIN_DATALOADERS
     13 from torch.utils.data.dataloader import DataLoader, default_collate

ModuleNotFoundError: No module named 'lightning'

Code of Conduct

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

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 24 (12 by maintainers)

Most upvoted comments

Sure, glad that it worked.

Yeah, pip install -r requirements/core.txt would only install the dependencies like torch, lightning etc.

If you want wand and openvino it would not install them you would need

pip install -r requirements/loggers.txt
pip install -r requirements/openvino.txt

However, if you run anomalib install, it should install all of these dependencies.

I have the same problem. I had pytorch lightning version that was not compatible, so I installed version 2 as recommended:

lightning>2,<2.2.0 # We need to sort out the compatibility with the latest version of Lightning.

Then I had another error: no module open_clip. So I installed the latest version of open clip. Now I have an error that I can’t solve: No module named ‘openvino.tools.ovc’ . I tried to install the openvino but no improvement. I installed it via git as well.