Skip to content
This repository was archived by the owner on Aug 4, 2026. It is now read-only.
This repository was archived by the owner on Aug 4, 2026. It is now read-only.

ModuleNotFoundError: No module named 'gemma' when importing Gemma3ForMultimodalLM #107

Description

@loki52501

Description

Importing Gemma3ForMultimodalLM from gemma_pytorch.gemma.gemma3_model fails with:

ModuleNotFoundError: No module named 'gemma'

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/tmp/ipykernel_2276/2279190376.py in <cell line: 0>()
      1 from gemma_pytorch.gemma.config import get_model_config
----> 2 from gemma_pytorch.gemma.gemma3_model import Gemma3ForMultimodalLM
      3 
      4 import os
      5 import torch

/content/gemma_pytorch/gemma/gemma3_model.py in <module>
     22 from typing import Any, List, Sequence, Tuple, Union
     23 
---> 24 from . import model as gemma_model
     25 from . import config as gemma_config
     26 from . import gemma3_preprocessor

/content/gemma_pytorch/gemma/model.py in <module>
     22 from typing import Any, List, Optional, Sequence, Tuple, Union, Mapping
     23 
---> 24 from gemma import config as gemma_config
     25 from gemma import tokenizer
     26 

ModuleNotFoundError: No module named 'gemma'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------


## Steps to reproduce

In a notebook/cloud kernel environment:

```python
from gemma_pytorch.gemma.config import get_model_config
from gemma_pytorch.gemma.gemma3_model import Gemma3ForMultimodalLM

Actual behavior

The import fails with:

ModuleNotFoundError: No module named 'gemma'

Full traceback:

from gemma_pytorch.gemma.config import get_model_config
from gemma_pytorch.gemma.gemma3_model import Gemma3ForMultimodalLM

# ...
# /content/gemma_pytorch/gemma/model.py in <module>
# ---> 24 from gemma import config as gemma_config
#      25 from gemma import tokenizer
#
# ModuleNotFoundError: No module named 'gemma'

Expected behavior

Gemma3ForMultimodalLM should import successfully when using the package namespace:

from gemma_pytorch.gemma.gemma3_model import Gemma3ForMultimodalLM

Suggested fix

In gemma/model.py, change the absolute imports:

from gemma import config as gemma_config
from gemma import tokenizer

to relative imports:

from . import config as gemma_config
from . import tokenizer

This matches how gemma3_model.py already imports sibling modules:

from . import model as gemma_model
from . import config as gemma_config
from . import gemma3_preprocessor

Environment

  • Environment: Cloud notebook/kernel
  • Package path used: gemma_pytorch.gemma
  • Python: 3.13

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions