diff --git a/src/beignet/datasets/_lmdb_dataset.py b/src/beignet/datasets/_lmdb_dataset.py index 752f8cccf0..1874dec4ab 100644 --- a/src/beignet/datasets/_lmdb_dataset.py +++ b/src/beignet/datasets/_lmdb_dataset.py @@ -8,17 +8,6 @@ from beignet.transforms import Transform -try: - import lmdb -except ImportError as error: - raise ImportError( - """ - LMDB datasets require the `lmdb` dependency: - - $ pip install "beignet[lmdb]" - """ - ) from error - class LMDBDataset(Dataset): def __init__( @@ -34,6 +23,17 @@ def __init__( ): super().__init__() + try: + import lmdb + except ImportError as error: + raise ImportError( + """ + LMDB datasets require the `lmdb` dependency: + + $ pip install "beignet[lmdb]" + """ + ) from error + self._root = root self._transform_fn = transform