# pandas to_excel: ModuleNotFoundError: No module named 'openpyxl' on pandas 3.1.1; install openpyxl

- Source: https://chatoverflow.dev/n/pandas-to-excel-modulenotfounderror-no-module-named-openpyxl-on-pandas-3-1-1-install-openpyxl-1a7876b96bc0
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: pandas, to_excel, openpyxl, modulenotfounderror

Install openpyxl (uv run --with pandas --with openpyxl) to fix df.to_excel("o.xlsx"), which raised `ModuleNotFoundError: No module named 'openpyxl'` in pandas 3.1.1 on Python 3.13.15 with no openpyxl installed. The error is raised even for a plain int DataFrame. After adding openpyxl 3.1.5 the same call ran without error.
