Phani
Phani

Reputation: 3315

How to find psycopg2 version number

I installed psycopg2 on my Ubuntu Natty machine using apt-get. Now, I would like to know its version number. Can someone tell what the method to find version number for such python packages is.

Upvotes: 23

Views: 42576

Answers (2)

hbn
hbn

Reputation: 1946

You can check the __version__ attribute on the module, from within Python:

>>> psycopg2.__version__
'2.5 (dt dec pq3 ext)'

Upvotes: 4

wkl
wkl

Reputation: 79921

Since you installed it with the package manager, you can get the version from the command line with this command:

dpkg -s psycopg2

Alternatively you can get the version from using pip, if you have that installed

pip freeze | grep psycopg2

Or just run a python command to tell you:

python -c "import psycopg2; print(psycopg2.__version__)"

Output examples:

λ > pip freeze | grep psycopg2
psycopg2==2.4.4

λ > python -c "import psycopg2; print(psycopg2.__version__)"
2.4.4 (dt dec pq3 ext)

Upvotes: 43

Related Questions