How to install openpyxl in Python
Hello, Coders!! In this Python tutorial, we will learn about how we can install the openpyxl library in Python for Windows and Linux systems.
The openpyxl is a Python library that is used for reading and writing Excel files with extensions like xlsx, xlsm, xltx, xltm. It provides various different modules to deal with Excel files without involving any other third-party software.
In this tutorial, we will install the openpyxl module by using the Python package manager(pip
). The pip
package manager helps us in installing and managing additional packages that do not come with the Python standard library.
The syntax for installing openpyxl using pip:
$ pip install package_name
Installing openpyxl In Python For Windows
Step1: Open the CMD or PowerShell on the screen.
Step2: Then by using the pip
package manager, install openpyxl package.
pip install openpyxl
Output:
Done!! We have successfully installed the openpyxl package on the Windows system.
Alternative Method To Install openpyxl In Python For Windows
In any case, the pip
package manager doesn’t work, then we can install the openpyxl package manually.
Step1: Download the openpyxl package for windows from the official website. (https://pypi.org/project/openpyxl/)
Step2: Click on the Download Files and download the openpyxl package by clicking on the openpyxl.x.x.x.tar.gz file link. (x.x.x is denoted to the version number)
Step3: Now go to the C:\Downloads directory and extract the openpyxl TAR file.
Note: Extract the package in the Python folder on C:\ drive.
Step4: Open the CMD or PowerShell and change the directory location to the extracted openpyxl package file.
Step5: Finally, run the setup file given inside the openpyxl package file for installation.
> py setup.py install
Install openpyxl In Python For Linux
Like the Windows system, we can also install the openpyxl package on Linux too. Here we use the pip
for installing the package as well.
Step1: Open the terminal by pressing Ctrl+Alt+T.
Step2: Use the pip
command to install the openpyxl.
$ sudo pip install openpyxl
Output:
Hope you enjoyed this article and learned how to install the openpyxl package in Python for Windows and Linux systems.
Happy Coding!!!
You can also read, How to add color to Excel cells using Python
Hi , I am getting the error message “Defaulting to user installation because normal site-packages is not writeable” in the command prompt. Please advise. Thanks Arko.