Odoo: No module named 'pkg_resources' (tested fix)

Odoo 16.0 does import pkg_resources at the top of odoo/modules/module.py, so on setuptools 82 or newer even odoo-bin --version fails with ModuleNotFoundError: No module named 'pkg_resources'. Tested fix: pip install "setuptools<81".

1. The error: Odoo 16.0 with setuptools 84

Odoo 16.0 source (branch head e46fb65, 2026-10-23), its requirements.txt installed into a Python 3.11.17 venv, setuptools 84.2.1. Even --version fails, before any config or database is touched:

$ python odoo-bin --version
Traceback (most recent call last):
  File "/opt/odoo/odoo-bin", line 5, in <module>
    import odoo
  File "/opt/odoo/odoo/__init__.py", line 135, in <module>
    from . import modules
  File "/opt/odoo/odoo/modules/__init__.py", line 8, in <module>
    from . import db, graph, loading, migration, module, registry, neutralize
  File "/opt/odoo/odoo/modules/graph.py", line 10, in <module>
    import odoo.tools as tools
  File "/opt/odoo/odoo/tools/__init__.py", line 23, in <module>
    from .image import *
  File "/opt/odoo/odoo/tools/image.py", line 18, in <module>
    from odoo.tools.translate import _
  File "/opt/odoo/odoo/tools/translate.py", line 30, in <module>
    from odoo.modules.module import get_resource_path
  File "/opt/odoo/odoo/modules/module.py", line 11, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

odoo/modules/module.py line 11 is a plain import pkg_resources, and setuptools 82.0.0 removed that module. Odoo 16's requirements.txt does not list setuptools, so a fresh venv on Python 3.12 or newer (which ships no setuptools) or any venv where setuptools was upgraded hits this.

2. Fix for Odoo 16 and older: pin setuptools below 81 (tested)

$ pip install "setuptools<81"    # gave 80.10.2
$ python odoo-bin --version
/opt/odoo/odoo/modules/module.py:11: 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
Odoo Server 16.0

It starts, with the pkg_resources is deprecated as an API warning. To hide that too:

$ PYTHONWARNINGS="ignore:pkg_resources is deprecated as an API" python odoo-bin --version
Odoo Server 16.0

Put the pin in the same place you install Odoo's requirements (for example add setuptools<81 to your own requirements file or Dockerfile), or the next pip install -U setuptools brings the error back.

3. Odoo 17 and 18

We did not run these; this is from the source. The current 17.0 branch wraps the import in try/except ImportError and falls back to importlib.metadata:

try:
    from pkg_resources import DistributionNotFound, VersionConflict, get_distribution
except ImportError:
    class DistributionNotFound(Exception):
        ...

The 18.0 branch's module.py no longer mentions pkg_resources at all. Older 17.0 checkouts may predate that fallback, so pull the latest 17.0 if you see this error there.

Our venv used psycopg2-binary at the same pinned version instead of psycopg2, and left out python-ldap (it needs system LDAP headers and is only used by the LDAP login module). Neither touches this import.

Related: No module named 'pkg_resources' (general fix) · Home Assistant · docker build.

Frequently asked questions

Is Odoo 16.0 fixed upstream?

Not as of commit e46fb65 (2026-10-23): module.py line 11 still imports pkg_resources unguarded, and we reproduced the error on that commit.

Does the fix change Odoo behaviour?

No. setuptools 80.10.2 still includes pkg_resources, so Odoo 16 runs exactly as before; it only prints a deprecation warning, which PYTHONWARNINGS can hide.

Written with AI assistance. Measured on 2026-10-24 on Linux with Odoo 16.0 (commit e46fb65), CPython 3.11.17, setuptools 80.10.2 and 84.2.1. Output pasted unedited except shortened paths. PlainTables is our extension; Odoo Community is free.