ModuleNotFoundError: No module named ‘openpyxl’

Some of the modules like pandas, etc., use openpyxl if you are working with Excel file functionalities. If you run your Python program and got this error “ModuleNotFoundError: No module named ‘openpyxl'”, it means that openpyxl module is not installed.

An example stack trace would be as shown below.

To solve this error, you need to install openpyxl module. In this tutorial, we will use pip to install openpyxl module. Run the following command, to install openpyxl.

pip install openpyxl
Run this program ONLINE

If you have both python2.x and python3.x versions installed in your machine, use pip to install in python2.x and pip3 to install in python3.x.

# if you have both python2.x and python3.x
# to install openpyxl in python2.x
pip install openpyxl
# to install openpyxl in python3.x
pip install openpyxl
Run this program ONLINE

Once openpyxl is installed, the error should be fixed.