How to print version number of a Python module

In this tutorial, we will learn how to print the version number of a Python module. When you install Python, you get the Python package manager i.e pip along with it. The pip performs many functions.

  • Helps to install Python packages with a simple command
pip install <package_name>
  • Used to extract features like version number
    Our problem statement for this tutorial is also to find out the version number of Python module. So let’s get started.

Finding out version number of a Python module

Basically there are a number of ways to find out and print version number of a Python module. One of the simplest way is as shown.

  • Open cmd and type python.
  • import the package and use .__version__ to print the package number.
import numpy
print(numpy.__version__)

Another way: If you want to see all the installed Python packages with corresponding version number use:

pip freeze

One more similar command is as shown below:

pip list

Note:  In some cases, pip is used for Python2, while pip3 is used for Python3.

Another way:  If we want more info about the package, like version, summary, requirements, we go with the below command.

pip show <package-name>

So, these are some simple and easy ways to check and print the version number of a Python module.

I hope you loved the tutorial. For more such tutorials stay tuned with CodeSpeedy.

Also read: Python Modules

Leave a Reply

Your email address will not be published. Required fields are marked *