How to check version of aiohttp

Question:

How do I check in Ubuntu 16.04, which version of aiohttp is installed?

This works

 python -V
 Python 2.7.12    

but this doesn’t

aiohttp -V
-bash: aiohttp: command not found
Asked By: GoodtheBest

||

Answers:

It is not a command line tool. That’s why it says command not found. It is a pip package. So, you can do this:

pip freeze | grep aiohttp

to find the version.

Answered By: Jahongir Rahmonov

If you installed it with pip (>= 1.3), use

$ pip show aiohttp

For older versions,

$ pip freeze | grep aiohttp

pip freeze has the advantage that it shows editable VCS checkout versions correctly, while pip show does not.

… or

$ pip list | grep aiohttp
$ pip list --outdated | grep aiohttp

(--outdated to see Current and Latest versions of the packages).

Credits: Find which version of package is installed with pip

Note: the property __version__ comes in handy, but it is not always available. This is an issue that evolved with time. YMMV.

A general way that works for pretty much any module, regardless of how it was installed is the following:

$ python -c "import aiohttp; print(aiohttp.__version__)"
2.3.3

What this does is run a Python interpreter, import the module, and print the module’s __version__ attribute. Pretty much all Python libraries define __version__, so this should be very general (especially since __version__ is recommended by PEP8).

This is analogous to:

$ python
>>> import aiohttp
>>> print(aiohttp.__version__)
2.3.3
>>> quit()
Answered By: Alexander Huszagh
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.