I can not get any of the z3py examples to work. I was able to install it successful using the instructions from the README on github. I successfully updated my python path to point to the appropriate directory. Furthermore, I was able to successfully import z3, but I get an error every time I declare a variable. The compiler does not recognize Int, Ints, Real , RealVal.
I have included an example to illustrate.
Code:
from z3 import *
x = Int('x')
y = Int('y')
solve(x > 2, y < 10, x + 2*y == 7)
Error: Traceback (most recent call last): File "test.py", line 3, in x = Int('x') NameError: name 'Int' is not defined
I would really appreciate any help. Thank you so much.
dir()show you afterfrom z3 import *? Have you instead triedimport z3; x = z3.Int('x')? - nekomaticfrom z3 import * dir() >>>['__builtins__', '__doc__', '__name__', '__package__'] >>> x = Int('x') Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'Int' is not defined>>> import z3 >>> x = Int('x') Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'Int' is not defined- Akanksha Vyasimporta module it should appear in the result ofdir(), so I would check whether you've installed z3 properly. - nekomaticimport z3then tryx = z3.Int('x'), and so on. - nekomaticz3.pyin your working dir? It shadows installed package. - Ćukasz Rogalski