Python: Check Package Version

While working with Python you may wonder what is the version of a certain Python package (library) that you are using.

There are several ways of how to get the version of a package or module in Python.

This note describes how to check the version of Python packages from a Python shell, from a command-line (terminal) or using a pip command.

Cool Tip: How to list all the locally installed Python modules and find the paths to their source files! Read More →

Check Version of Python Package

You can get the version of a Python package by running the command as follows directly from a Python shell:

$ python
Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources; print(pkg_resources.get_distribution('selenium').version)
- sample output -
4.3.0

To check the Python package version you can also run the above command from a command-line (terminal) as follows:

$ python -c "import pkg_resources; \
             print(pkg_resources.get_distribution('selenium').version)"
- sample output -
4.3.0

To get the Python package version using a pip, execute:

$ pip show selenium
- sample output -
Name: selenium
Version: 4.3.0
Summary: None
Home-page: https://www.selenium.dev
Author: None
Author-email: None
License: Apache 2.0
Location: /projects/myApp/venv/lib/python3.8/site-packages
Requires: trio, trio-websocket, urllib3
Required-by: 

Cool Tip: How to list dependencies of the installed Python packages! Read More →

You can also check the Python package version using the pip as follows:

$ pip freeze | grep selenium
- sample output -
selenium==4.3.0

Leave a Reply