Skip to content

python-jsonpath namespace collides with jsonpath PyPI package #128

@gil-ch-palo

Description

@gil-ch-palo

python-jsonpath installs into the jsonpath/ namespace in site-packages, which conflicts with the existing jsonpath package (by Phil Budne, published since 2008).

When both are installed in the same environment (e.g., as transitive dependencies), python-jsonpath's jsonpath/ directory shadows the original jsonpath.py module. Code that does from jsonpath import jsonpath (the original package's API) breaks with:
ImportError: cannot import name 'jsonpath' from 'jsonpath'

This is happening in practice: kr8s depends on python-jsonpath, and projects that also depend on the original jsonpath encounter this collision.

Reproduction:
pip install jsonpath==0.82.2 python-jsonpath
python -c "from jsonpath import jsonpath"
# ImportError: cannot import name 'jsonpath' from 'jsonpath'

Suggestion:
Would you consider using a non-colliding import namespace, such as python_jsonpath or pyjsonpath? This would allow python-jsonpath to coexist with the original jsonpath package. The current situation makes it impossible to have both in the same environment, even indirectly via transitive dependencies.

I understand this would be a breaking change for existing users. A migration path could include a major version bump and a compatibility shim that re-exports the new namespace from the old one for a deprecation period.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions