Skip to content

weaviate-client 4.20.5+ imports packaging without declaring it as a dependency #2022

@ducroq

Description

@ducroq

Summary

Since v4.20.5, weaviate-client imports from packaging import version at module load (in weaviate/exceptions.py) but packaging is not declared in the project's install requirements. In environments that don't already have packaging installed transitively, every import weaviate raises ModuleNotFoundError: No module named 'packaging'.

This is most visible in slim/minimal Python container images (e.g. python:3.12-slim, python:3.14-slim), where packaging is not preinstalled.

Reproduction

FROM python:3.12.8-slim
RUN pip install --no-cache-dir weaviate-client==4.21.0
RUN python -c "import weaviate"

Result:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.12/site-packages/weaviate/__init__.py", line 13, in <module>
    from . import (
  File "/usr/local/lib/python3.12/site-packages/weaviate/backup/__init__.py", line 3, in <module>
    from .async_ import _BackupAsync
  File "/usr/local/lib/python3.12/site-packages/weaviate/backup/async_.py", line 1, in <module>
    from weaviate.backup.executor import _BackupExecutor
  File "/usr/local/lib/python3.12/site-packages/weaviate/backup/executor.py", line 20, in <module>
    from weaviate.connect import executor
  File "/usr/local/lib/python3.12/site-packages/weaviate/connect/__init__.py", line 3, in <module>
    from .base import ConnectionParams, ProtocolParams
  File "/usr/local/lib/python3.12/site-packages/weaviate/connect/base.py", line 13, in <module>
    from weaviate.util import is_weaviate_domain
  File "/usr/local/lib/python3.12/site-packages/weaviate/util.py", line 19, in <module>
    from weaviate.exceptions import (
  File "/usr/local/lib/python3.12/site-packages/weaviate/exceptions.py", line 9, in <module>
    from packaging import version
ModuleNotFoundError: No module named 'packaging'

Reproducible on weaviate-client==4.20.5, 4.20.6, ..., 4.21.0. Not reproducible on weaviate-client==4.20.4 and earlier.

Suspected cause

In v4.20.5, PR #1999 dropped the unmaintained deprecation dependency in favor of stdlib (fix(deps): remove unmaintained deprecation package, use stdlib instead).

The deprecation package depends on packaging. When it was removed from weaviate-client's declared deps, packaging was no longer reaching the install environment transitively — but weaviate/exceptions.py still imports packaging.version directly.

Expected behavior

packaging should be declared as a direct dependency of weaviate-client (in pyproject.toml / setup.py), so any environment that installs weaviate-client gets packaging automatically.

Why this slips through CI

Most CI environments already have packaging installed because pip itself depends on it, or because an unrelated package in the test env pulls it in transitively. The bug only surfaces in minimal Python images where import weaviate is the first thing that needs packaging.

Workaround

Add packaging explicitly to your own requirements file:

weaviate-client==4.21.0
packaging>=23.0

Suggested fix

Add to pyproject.toml:

[project]
dependencies = [
  ...
  "packaging>=21.0",  # used in weaviate.exceptions
]

Happy to send a PR if that helps.

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