weaviate-client 4.20.5+ imports `packaging` without declaring it as a dependency
envgap__weaviate__weaviate-python-client-2022
01 / FAILURE SIGNATURE
As reported upstream
ModuleNotFoundError: No module named 'packaging'
Not a benchmark task.
- The project already builds and runs before the fix, so there is nothing to repair.
02 / ENVIRONMENT RECIPE
- Base commit
1214b4beb1de55fd94a3ce2ce3775a04b6f42dd0- Manifest
requirements-devel.txt- Reproduce
Awaiting issue-specific recipe- Run under trace
Awaiting a meaningful runtime command
03 / ORIGINAL ISSUE TEXT
weaviate/weaviate-python-client #2022 · read the original issue
## 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
```Dockerfile
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](https://github.com/weaviate/weaviate-python-client/pull/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:
```text
weaviate-client==4.21.0
packaging>=23.0
```
## Suggested fix
Add to `pyproject.toml`:
```toml
[project]
dependencies = [
...
"packaging>=21.0", # used in weaviate.exceptions
]
```
Happy to send a PR if that helps.04 / LABELS
Labels from the report text only; not yet run
No supported category has been assigned.
Label rules and the text that matched
[]