h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
603 stars 87 forks source link

Importing test library 'REST' failed: ModuleNotFoundError: No module named 'jsonpath_ng.bin'; 'jsonpath_ng' is not a package #36

Closed mayuresh1612 closed 4 years ago

mayuresh1612 commented 4 years ago

For jsonpath-ng 1.5.0 released today got some issue

Importing test library 'REST' failed: ModuleNotFoundError: No module named 'jsonpath_ng.bin'; 'jsonpath_ng' is not a package

Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/REST/init.py", line 37, in from .keywords import Keywords File "/usr/local/lib/python3.8/site-packages/REST/keywords.py", line 34, in from jsonpath_ng.ext import parse as parse_jsonpath File "/usr/local/bin/jsonpath_ng.py", line 5, in from jsonpath_ng.bin.jsonpath import entry_point

Please Note: Working fine with jsonpath-ng==1.4.3

gaborbernat commented 4 years ago

@h2non this is related to https://github.com/h2non/jsonpath-ng/pull/25; that name choice for the executable is a really bad idea. I'd recommend dropping the .py extension, it's not common for executables.

Python puts the current working directory always on the path, as first entry, see https://docs.python.org/3/tutorial/modules.html#the-module-search-path. So if someone executes import jsonpath_ng from the binary folder Python will import the generated console script as jsonpath_ng, which in turn, of course, does not have the needed sub-packages.

cc @rahendatri for awareness

h2non commented 4 years ago

This should be fixed in v1.5.1, now available on PyPI. To upgrade, please run: pip install --upgrade jsonpath-ng

gaborbernat commented 4 years ago

Thanks 👍