Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing issue while using jmespath in docker #320

Open
sunilgsuthar opened this issue Nov 8, 2023 · 1 comment
Open

Facing issue while using jmespath in docker #320

sunilgsuthar opened this issue Nov 8, 2023 · 1 comment

Comments

@sunilgsuthar
Copy link

So this is my file:

import jmespath
a = {
    "z": 2,
    "x": 3,
    "c": 4
}

e1 = "z + x"
e2 = "x * c"

print(jmespath.search(e1, a))
print(jmespath.search(e2, a))

Also this is my docker file:

FROM python:3.9-alpine

RUN pip install jmespath jmespath-community

COPY my-test.py .

CMD ["python", "my-test.py"]

The same code works when I just run the python file. But when run through docker, this throws these kind of errors:

  File "//my-test.py", line 12, in <module>
    print(jmespath.search(e1, a))
  File "/usr/local/lib/python3.9/site-packages/jmespath/__init__.py", line 12, in search
    return parser.Parser().parse(expression).search(data, options=options)
  File "/usr/local/lib/python3.9/site-packages/jmespath/parser.py", line 88, in parse
    parsed_result = self._do_parse(expression)
  File "/usr/local/lib/python3.9/site-packages/jmespath/parser.py", line 96, in _do_parse
    return self._parse(expression)
  File "/usr/local/lib/python3.9/site-packages/jmespath/parser.py", line 109, in _parse
    self._tokens = list(self.tokenizer)
  File "/usr/local/lib/python3.9/site-packages/jmespath/lexer.py", line 107, in tokenize
    raise LexerError(lexer_position=self._position,
jmespath.exceptions.LexerError: Bad jmespath expression: Unknown token +:
z + x

Is there something we are doing wrong? because the same code works on local, but not when deployed to a server through docker.

@ftnt-dspille
Copy link

@sunilgsuthar I'm just curious, is there a reason why you install both jmespath and jmespath-community ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants