Checking the version of Python module

With PIP, you can list all module versions with the following command:

pip freeze

Check versions of the selected modules

The problem with displaying all these modules occurs when there are dozens or even hundreds of them on the particular machine.

If you know the name of a module to check, you can use additional parameters: findstr for Windows and grep for Linux.

Windows

For Windows, this command looks like this and it’s case sensitive.

pip freeze | findstr numpy

In my case, the command will return the following result:

numpy==1.16.2

If you want to return multiple results, you can use module names in double-quotes, separated by space.

pip freeze | findstr "numpy Django mysql"

In the case of my system, this command returns versions of three modules:

Django==3.0.3
mysqlclient==1.4.6
numpy==1.16.2

Linux

Instead of findstr, Linux uses grep to search for results:

pip freeze | grep boto

This command will display:

boto==2.34.0

If you want to search for multiple modules use the following command:

pip freeze | grep -E "boto|requests|numpy"

This result (on my computer) returns this result:

boto==2.34.0
requests==2.4.3

It didn’t return the numpy version, because there is no numpy module on the machine.