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.
There is something wrong with your local installation, either of Python or Z3.
I just compiled Z3 on my Mac and ran the example test.py
you provided with no problems. I'm using OS X 10.9.5 with Python 2.7.11 and the current master version of Z3 (commit 41edf5f). The exact instructions I used were:
git clone https://github.com/Z3Prover/z3.git
cd z3
./configure
cd build
make -j4
emacs test.py
# Write in the example you gave.
python ./test.py
The output I got was [y = 0, x = 7]
, which is the same output that I got from your script on my Linux box. So the problem is specific to your OS X machine or build procedure.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.