How to Install openpyxl in Python

v3.1.5 General Purpose Python >=3.8 MIT

A Python library to read/write Excel 2010 xlsx/xlsm files

Install pip install openpyxl

What is openpyxl?

A Python library to read/write Excel 2010 xlsx/xlsm files

openpyxl is a Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files.

It was born from lack of existing library to read/write natively from Python the Office Open XML format.

All kudos to the PHPExcel team as openpyxl was initially based on PHPExcel.

Quick Start

Minimal example to get started with openpyxl:

from openpyxl import Workbook

wb = Workbook()
ws = wb.active
ws.title = "Sales"
ws["A1"] = "Month"
ws["B1"] = "Revenue"
ws.append(["January", 12500])
ws.append(["February", 14200])
wb.save("report.xlsx")

Installation

pip (standard)

pip install openpyxl

Virtual environment (recommended)

python -m venv venv
source venv/bin/activate   # Windows: venv\Scripts\activate
pip install openpyxl

pip3

pip3 install openpyxl

conda

conda install -c conda-forge openpyxl

Poetry

poetry add openpyxl

Dependencies

Installing openpyxl will also install these packages:

Verify the Installation

After installing, confirm the package is available:

python -c "import openpyxl; print(openpyxl.__version__)"

If this prints a version number, installation succeeded. If you see a ModuleNotFoundError, see the errors section below.

Installation Errors

Common errors when installing openpyxl with pip.

ModuleNotFoundError: No module named 'openpyxl'

Cause: The package is not installed in the current Python environment.

Fix: Run pip install openpyxl. If using a virtual environment, ensure it is activated first.

ModuleNotFoundError: No module named 'openpyxl' (installed but still failing)

Cause: pip installed the package into a different Python than the one running your script.

Fix: Use python -m pip install openpyxl to install into the interpreter you are running.

ImportError: cannot import name 'X' from 'openpyxl'

Cause: The function or class does not exist in the installed version.

Fix: Check the version with pip show openpyxl and upgrade with pip install --upgrade openpyxl.

pip: command not found

Cause: pip is not in PATH or Python was not added to PATH during installation.

Fix: Try python -m pip install openpyxl. On macOS/Linux try pip3.

PermissionError: [Errno 13] Permission denied

Cause: No write access to the system Python package directory.

Fix: Use a virtual environment, or add --user: pip install --user openpyxl

SSL: CERTIFICATE_VERIFY_FAILED

Cause: pip cannot verify PyPI's SSL certificate — common behind corporate proxies.

Fix: Try: pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org openpyxl

Recent Releases

VersionReleased
3.1.5 latest 2024-06-28
3.1.4 2024-06-12
3.1.3 2024-05-29
3.1.2 2023-03-11
3.1.1 2023-02-13

Full release history on PyPI →

Manage openpyxl

Upgrade to latest version

pip install --upgrade openpyxl

Install a specific version

pip install openpyxl==3.1.5

Uninstall

pip uninstall openpyxl

Check what is installed

pip show openpyxl

Last updated: 2026-04-11 • Data from PyPI