Skip to content

Module pkg_resources not found. Problems running examples. #462

@lennarteing

Description

@lennarteing

Description:

I was trying to run the sam3_video_predictor_example.ipynb notebook and encountered this problem when import sam3 is called:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[10], line 2
      1 import os
----> 2 import sam3
      3 import torch
      5 sam3_root = os.path.join(os.path.dirname(sam3.__file__), "..")

File ~/sam3/sam3/__init__.py:5
      1 # Copyright (c) Meta Platforms, Inc. and affiliates. All Rights Reserved
      2 
      3 # pyre-unsafe
----> 5 from .model_builder import build_sam3_image_model
      7 __version__ = "0.1.0"
      9 __all__ = ["build_sam3_image_model"]

File ~/sam3/sam3/model_builder.py:8
      5 import os
      6 from typing import Optional
----> 8 import pkg_resources
      9 import torch
     10 import torch.nn as nn

ModuleNotFoundError: No module named 'pkg_resources'

Reproduction:

mamba create -n sam3 python=3.12
mamba deactivate
mamba activate sam3
python -m pip install torch==2.7.0 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
git clone https://github.com/facebookresearch/sam3.git
cd sam3
pip install -e .
pip install -e ".[notebooks]"

Possible fix:

This problem could be fixed for me by pinning the setuptools package.

python -m pip install --force-reinstall "setuptools<82"

This did the trick for me.
This seems to happen because the pkg_resources package has been deprecated after setuptools==81.

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