How to check version of Python modules?

Check Version of Installed Python Modules: In this tutorial, we will learn how to check the version of installed Python modules using different ways. By Sapna Deraje Radhakrishna Last updated : June 21, 2023

The ideal way of installing python libraries are using PIP (Python Package Manager). PIP provides an option to verify the version of the installed modules.

Check version of installed Python modules using pip

The simplest way is to check the version of installed Python modules, you can use the pip freeze command. It returns the list of all modules with their installed versions.

The command to use to verify the version of the installed modules is:

pip freeze

Result:

(venv) bash$:src XYZ$ pip freeze
notebook==6.0.2
numpy==1.17.2
openpyxl==3.0.2
pandas==0.25.3
pandocfilters==1.4.2
parso==0.5.2
pexpect==4.7.0
pickleshare==0.7.5
prometheus-client==0.7.1
prompt-toolkit==3.0.2
ptyprocess==0.6.0
Pygments==2.5.2
pynb==0.1.36
pyrsistent==0.15.6
python-dateutil==2.8.1
pytz==2019.3
pyzmq==18.1.1
qtconsole==4.6.0
Send2Trash==1.5.0
six==1.13.0
soupsieve==1.9.5
SQLAlchemy==1.3.12
terminado==0.8.3
testpath==0.4.4
tornado==6.0.3
traitlets==4.3.3
wcwidth==0.1.8
webencodings==0.5.1
widgetsnbextension==3.5.1

The above list might be very exhaustive and in order to verify the version of a given module use the below command,

(venv) bash:src XYZ$ pip freeze | grep pandas
pandas==0.25.3

Check version of installed Python modules using __version__ attribute

The another way is to check the version of installed Python modules by using the __version__ attribute. For this you have to write Python code.

Verify the version of the module (without using PIP) is as follows,

# import the module 
import pandas as pd 

# print the version 
print(pd.__version__)

Output

0.25.3

The above method is cumbersome in case we want to verify the version of multiple modules, as we have to write a print statement for every module. Hence the PIP way of verifying the version is preferred.

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.