Search code examples
pythonpipversiongoogle-colaboratoryz3

How can I know the version of a library in Google Colab? Trying it for Z3


I know I can manually install a concrete version of a library in Google Colab (see When I install older version of scikit-learn in Google Colab, it still import the newest version).

However, how can I know which version of a library I am using? I am trying to know which version of Z3 I am using.

I tested the following:

pip install z3-solver
import z3
z3 -version

But I get the following error: name 'version' is not defined

In my (Unix) machine, it suffices to ask: z3 -version (see Z3 -smt2 -in: Get Z3 version)

This question is extensible to any library.


Solution

  • You should use the dunder notation

    z3.__version__
    

    EDIT - for pip package z3-solver

    you should use

    import z3
    z3.get_version_string()
    

    as seen here