Search code examples
pythonpython-2.7z3z3py

Cannot import z3 in python-2.7.12 in ubuntu even after installation


I tried installing z3 theorem prover. I am using Ubuntu 16.04. And I am using Python 2.7.12

I did the installation in two ways:

  1. I used sudo apt-get install z3

    But when I tried to import z3 by opening python from terminal using from z3 import * and also using import z3 as z I got an error saying No Module named z3

  2. I used

    python scripts/mk_make.py cd build make sudo make install

and also added build/python to PYTHONPATH and build to LD_LIBRARY_PATH but I got the same problem when i tried to import z3 using the same way.

Now I tried running examples.py which is the folder build/python

And lo!!! No Error!!!

I also tried running other example files and I didn't get any error for them too.

Can anybody help me with the problem why I cannot import z3 when I open Python from terminal or any other folder outside of build/python?

EDIT:

I found out that I have to do adding the folders to the path every time I open a terminal outside of build/python


Solution

  • I found out that I have to add the paths everytime I open a new terminal window. Then only z3 can be imported from anywhere.