mim install: No module named 'pkg_resources' (tested fix)

openmim 0.3.9 (the latest) does import pkg_resources in mim/commands/list.py, so on setuptools 82 or newer every mim command, including mim install mmcv, fails with ModuleNotFoundError: No module named 'pkg_resources'. Tested fix: pip install "setuptools<81".

1. The error: mim 0.3.9 with setuptools 84

pip install openmim==0.3.9 (the latest release, 2023-06-28) into a Python 3.11.17 venv with pip 26.2.2 and setuptools 84.2.1:

$ mim --version
Traceback (most recent call last):
  File "/path/to/venv/bin/mim", line 4, in <module>
    from mim.cli import cli
  File "mim/__init__.py", line 16, in <module>
    from .commands import (
  File "mim/commands/__init__.py", line 2, in <module>
    from .download import download
  File "mim/commands/download.py", line 12, in <module>
    from mim.click import (
  File "mim/click/__init__.py", line 2, in <module>
    from .autocompletion import (
  File "mim/click/autocompletion.py", line 2, in <module>
    from mim.commands.list import list_package
  File "mim/commands/list.py", line 4, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Every mim command fails before it starts, including mim install mmcv, because mim/__init__.py imports all subcommands and mim/commands/list.py line 4 is a plain import pkg_resources (mim/utils/utils.py imports it too). setuptools 82.0.0 removed that module. This usually shows up after pip install -U pip setuptools, or in a fresh venv or Docker image that gets the newest setuptools.

2. Fix: pin setuptools below 81 (tested)

$ pip install "setuptools<81"    # gave 80.10.2
$ mim --version
mim/commands/list.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
mim, version 0.3.9
$ mim list
mim/commands/list.py:4: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
/usr/lib/python3.11/importlib/__init__.py:169: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  _bootstrap._exec(spec, module)
Package    Version    Source
---------  ---------  --------

Same venv, nothing else changed. (The table is empty because no OpenMMLab packages were installed yet.) There is no newer openmim to upgrade to: 0.3.9 is the latest on PyPI, and mim/commands/list.py on the GitHub main branch still has import pkg_resources on line 4 (last commit 2023-11-24, checked 2026-10-24). Put setuptools<81 in your requirements file or Dockerfile next to openmim so a later upgrade does not undo it.

3. Hide the deprecation warnings

On setuptools 80.x, mim prints the pkg_resources is deprecated as an API warning (twice for mim list, as shown above). It is harmless. To silence it:

$ PYTHONWARNINGS="ignore:pkg_resources is deprecated as an API" mim list
Package    Version    Source
---------  ---------  --------

If you don't need mim itself, installing OpenMMLab packages with plain pip also avoids mim's import. For mmcv that means choosing the matching wheel index for your PyTorch and CUDA versions yourself. We did not test an mmcv install in this run.

Related: No module named 'pkg_resources' (general fix) · OpenAI CLIP · Stable Diffusion WebUI.

Frequently asked questions

Is there an openmim version without pkg_resources?

No: 0.3.9 (2023-06-28) is the latest release and the GitHub main branch still imports it (checked 2026-10-24).

Does this break mmcv, mmdet or mmengine themselves?

This page only covers the mim command. In our test mim failed at import, before it ran pip, so nothing was installed.

Written with AI assistance. Measured on 2026-10-24 on Linux with openmim 0.3.9, pip 26.2.2, CPython 3.11.17, setuptools 80.10.2 and 84.2.1. Output pasted unedited except shortened paths and one unrelated distutils warning removed from the traceback. PlainTables is our extension; OpenMMLab mim is free.