Python Forum
problem using pyeval_expression
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem using pyeval_expression
#1
hi
i found the below code in a net page( i do not know the exact address of it):
from pyeval_expression import Expression
expr=Expression(" 53 * -4 +2 * 3 ")
print(expr.result())
after running the code in idle, the below error appeared:
Error:
Traceback (most recent call last): File "D:\14020412_enteghal\akb_python\akb_py_projects\vscode_workspace\expr_test.py", line 1, in <module> from pyeval_expression import Expression ModuleNotFoundError: No module named 'pyeval_expression'
then in cmd, I wrote:
C:\WINDOWS\system32>pip install pyeval_expression
and the result is:
Output:
ERROR: Could not find a version that satisfies the requirement pyeval_expression (from versions: none) ERROR: No matching distribution found for pyeval_expression
My Python version is Python 3.11.5 .
what can I do to fix the problem?
thanks
Reply
#2
I search for pyeval_expression and find nothing. Where did you find a reference to this thing?
akbarza likes this post
Reply
#3
Code is not publish on PyPi,code is just a repo on GitHub.
Usage:
G:\div_code
λ git clone https://github.com/JFincher42/PyEval.git
Cloning into 'PyEval'...
remote: Enumerating objects: 44, done.
remote: Total 44 (delta 0), reused 0 (delta 0), pack-reused 44
Receiving objects: 100% (44/44), 9.38 KiB | 3.13 MiB/s, done.
Resolving deltas: 100% (16/16), done.

G:\div_code
λ cd PyEval\

G:\div_code\PyEval (master -> origin)
λ ls
debug-example.py  expr_test.py  Pipfile  pyeval_expression.py  pyeval_operand.py  pyeval_operator.py ev_test.py

G:\div_code\PyEval (master -> origin)
λ python ev_test.py
53 -4 * 2 3 * +

G:\div_code\PyEval (master -> origin)
λ cat ev_test.py
from pyeval_expression import Expression

expr=Expression(" 53 * -4 +2 * 3 ")
print(expr.result())
akbarza likes this post
Reply
#4
Maybe this one? Name is similar but not exact.

On PyPi.

pip install py-expression-eval

/regards
Reply
#5
(Oct-30-2023, 02:30 PM)popejose Wrote: Maybe this one? Name is similar but not exact.

On PyPi.

pip install py-expression-eval

/regards

hi
I used cmd for the command: pip install py-expression-eval
and then I changed the code to:
from py_expression_eval import Expression
expr=Expression(" 53 * -4 +2 * 3 ")
print(expr.result())
but the below error was shown:
Error:
Traceback (most recent call last): File "D:\14020412_enteghal\akb_python\akb_py_projects\py_expression_eval_example.py", line 7, in <module> expr=Expression(" 53 * -4 +2 * 3 ") TypeError: Expression.__init__() missing 3 required positional arguments: 'ops1', 'ops2', and 'functions'
Reply
#6
(Oct-31-2023, 10:57 AM)akbarza Wrote: I used cmd for the command: pip install py-expression-eval
and then I changed the code to:
Then you most follow the Doc py-expression-eval.
>>> from py_expression_eval import Parser
>>> 
>>> parser = Parser()
>>> p = parser.parse('53 * (-4) +2 * 3')
>>> p.evaluate({})
-206
Or Simpleeval.
>>> from simpleeval import simple_eval
>>> 
>>> simple_eval(" 53 * -4 +2 * 3 ")
-206
akbarza likes this post
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020