How to Install openpyxl Library in Python?

openpyxl Library in Python:

Openpyxl is a Python library for reading and writing Excel files with the xlsx, xlsm, xltx, and xltm extensions. It comes with a number of different modules that allow you to work with Excel files without having to use any third-party software.

Let us use the Python package manager pip to install the openpyxl module here. The pip package manager supports in the installation and management of additional Python packages that are not included in the standard library.

Installation:

pip install package_name

Output:

Collecting package_name
Downloading package_name-0.1.tar.gz (782 bytes)
Building wheels for collected packages: package-name
Building wheel for package-name (setup.py) ... done
Created wheel for package-name: filename=package_name-0.1-py3-none-any.whl size=1254 
sha256=5704546ee196cfea91be74986fddb721d38e9f6063d138b8e1eb00d6f7b3699b
Stored in directory: /root/.cache/pip/wheels/aa/56/2f/2bf8ec875b1c71660b2692b4aab073132abc
78ac076140489b
Successfully built package-name
Installing collected packages: package-name
Successfully installed package-name-0.1

Installation of openpyxl in windows

Open the command prompt and type the below command for the installation of the openpyxl package.

pip install openpyxl

Output:

Collecting openpyxl
Downloading openpyxl-3.0.9-py2.py3-none-any.whl (242 kB)
|████████████████████████████████| 242 kB 1.6 MB/s
Collecting et-xmlfile
Downloading et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
Installing collected packages: et-xmlfile, openpyxl
Successfully installed et-xmlfile-1.1.0 openpyxl-3.0.9

Installation of openpyxl in Windows
The openpyxl package is installed successfully on your Windows system

Another Way to Install openpyxl Library in Windows

We can install the openpyxl package using the pip package manager; however, if the above technique fails to install the package, we may still install the package manually from the official website on Windows.

Steps to be followed:

  1. To install the Mahotas package, go to the official website (https://pypi.org/project/openpyxl/)
  2. Navigate to the Download Files option and click on the openpyxl openpyxl.x.x.x.tar.gz file link to download the openpyxl package. (The version number of the package is denoted by x.x.x here)
  3. Installation of openpyxl library on Windows
  4. Go to the Downloads folder and extract the openpyxl TAR file there.
  5. The package should be extracted to the Python folder which is on the C:\ disk.
  6. Set the path to the extracted openpyxl package file in the CMD terminal to modify the directory.
  7. Finally, for package installation, run the setup file contained within the openpyxl package file.
  8. py setup.py install

Output:

installing openpyxl

Installation of  functools32 Library in Linux

We may also use the pip package manager to install the openpyxl package on a Linux system.

Steps to be followed:

  • Open the Linux terminal using Ctrl+Alt+T 
  • Type the below pip command for the installation of the openpyxl library.
$ sudo pip install openpyxl

The package openpyxl was successfully installed on the Linux system.

Installation of  functools32 Library using conda

Use the below command to install the openpyxl package using conda:

conda install -c anaconda openpyxl