DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How to Install openpyxl and Fix Common Python Import Errors

Install openpyxl with python -m pip in the same environment that runs your script. Learn how to create a virtual environment and fix common import errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install openpyxl into the same Python environment that runs your script. For most projects, create a virtual environment, activate it, then run python -m pip install openpyxl. If Python still reports ModuleNotFoundError: No module named 'openpyxl', check which interpreter your script, IDE, or notebook is actually using.

How do I install openpyxl?

The most reliable approach is to install the package in a project virtual environment. Python’s module installation guide describes venv as its standard tool for creating virtual environments, and the openpyxl installation guide advises using a virtual environment without system packages.

  1. Create an environment in your project directory: run python -m venv .venv.
  2. Activate it: in macOS or Linux shells, run source .venv/bin/activate. In Windows PowerShell, run .venvScriptsActivate.ps1. In Windows Command Prompt, run .venvScriptsactivate.bat.
  3. Install openpyxl: run python -m pip install openpyxl.
  4. Verify the package and import: run python -c "import openpyxl; print(openpyxl.__version__)". You can also start Python in that environment and try from openpyxl import Workbook.

Using python -m pip runs pip through the selected Python interpreter, rather than relying on a separate pip command that might belong to another installation. If you need a specific Python version, use its matching launcher: for example, python3.14 -m pip install openpyxl on a POSIX system, or py -3.14 -m pip install openpyxl on Windows. Replace 3.14 with the version you intend to use; the available command depends on how Python is installed.

Choose where to install the package

A virtual environment is a good default for a project because it keeps that project’s packages separate. You can also install into an existing interpreter or use a per-user installation when appropriate. Whichever option you choose, the application that runs your code must use the interpreter where openpyxl was installed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option Package isolation System-Python considerations Key check
Project virtual environment Packages are kept in the project’s environment. Avoids changing the system Python’s package set. Run the project with the environment’s interpreter.
Existing interpreter or per-user install Packages share that interpreter or user site rather than a project-only environment. Check whether the interpreter is managed by an operating system or another tool; Python warns that pip changes to a Linux distribution’s system Python can conflict with its package manager. Confirm the target application uses that same interpreter.

Activation is convenient but not required. Python documents that a virtual environment has its own package directories, and you can invoke its interpreter directly. For example, from a project directory, run .venv/bin/python -m pip install openpyxl on macOS or Linux, or .venvScriptspython.exe -m pip install openpyxl on Windows.

Why do I get ModuleNotFoundError: No module named 'openpyxl' after installing it?

The usual thing to check is whether installation and execution used different Python interpreters. A successful pip installation only confirms that the package was installed in the environment targeted by that pip command. An IDE, notebook kernel, scheduled task, or another terminal can run a different interpreter.

  • Install through the intended interpreter: use python -m pip install openpyxl in the environment that will run the script.
  • Check package metadata in that environment: run python -m pip show openpyxl from the same shell. This helps confirm which interpreter’s pip can see the package.
  • Run the import test where the error occurs: test from the IDE, notebook kernel, or runtime that executes your code—not only from a different terminal.
  • Select the project environment in your application: if an IDE or notebook uses another interpreter or kernel, point it to the project environment’s Python executable.

If you do not know which interpreter is being used, collect the exact install command, the command or application that runs the script, and the complete traceback. Those details are needed to distinguish an environment mismatch from another cause.

What if pip is missing or installation is blocked?

Python reports that pip is unavailable

Python’s installation guide lists python -m ensurepip --default-pip as one possible way to install pip. Whether it is available can depend on how Python was installed. Afterward, use python -m pip with the interpreter intended for your project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The interpreter is managed by the system

Do not assume that installing into a protected system interpreter is the right fix. Python warns that pip changes to a Linux distribution’s system Python can interfere with the distribution package manager. A project virtual environment avoids changing that system package set; a per-user install may also be appropriate in some setups.

What if the import works but opening a workbook fails?

If import openpyxl succeeds and an error occurs later at load_workbook(), Python has found the package. Investigate the workbook and the full traceback instead of reinstalling the package as the first response. The openpyxl documentation says the library follows OOXML and can reject invalid workbooks, so a workbook-format problem is distinct from a missing-module error.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do Pillow or lxml need to be installed?

No, neither is required for an ordinary openpyxl import or basic workbook creation. The documentation says Pillow is needed when embedding images in a workbook and can be installed separately with pip install pillow. It describes lxml as optional support that can be useful for creating large files.

For file-format scope, openpyxl’s project overview describes reading and writing Excel 2010 OOXML formats including .xlsx, .xlsm, .xltx, and .xltm. It does not support every Excel feature; its tutorial warns that shapes may be lost when an existing file is opened and saved.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.