Last modified: Nov 24, 2025 By Alexander Williams
Fix Python ImportError: No Module Named pyexcel
Python developers often face ImportError. This error stops your code from running. It means Python cannot find the pyexcel module.
This guide explains common causes. We provide step-by-step solutions. You will fix this error quickly.
Understanding the ImportError
The ImportError occurs when importing fails. Python cannot locate the pyexcel module. This happens for several reasons.
The module might not be installed. It could be in the wrong environment. There might be name conflicts too.
You might see this error message:
import pyexcel
Traceback (most recent call last):
File "script.py", line 1, in
import pyexcel
ModuleNotFoundError: No module named 'pyexcel'
Check pyexcel Installation
First, verify if pyexcel is installed. Use Python's package manager pip. Run this command in your terminal.
pip show pyexcel
If installed, you see package information. If not, you get a warning. Then you need to install it.
Install pyexcel using pip. This command downloads and installs the package.
pip install pyexcel
After installation, verify again. Use the show command to confirm.
Use Virtual Environments
Virtual environments isolate Python projects. They prevent package conflicts. Always use them for better management.
You might have installed pyexcel globally. But your project uses a virtual environment. So it cannot find the module.
Activate your virtual environment first. Then install pyexcel inside it. This ensures your project can access it.
Follow our guide on Install pyexcel in Python with pip and Virtualenv. It provides detailed steps for proper setup.
# Create virtual environment
python -m venv myenv
# Activate on Windows
myenv\Scripts\activate
# Activate on macOS/Linux
source myenv/bin/activate
# Install pyexcel
pip install pyexcel
Check Python Environment
Multiple Python versions can cause confusion. You might install pyexcel for one version. But run code with another.
Verify your Python and pip versions. Ensure they point to the same installation. This prevents environment mismatches.
# Check Python version
python --version
# Check pip version
pip --version
# Check pip location
which pip
Use python -m pip instead of just pip. This ensures using the correct Python's pip. It avoids version conflicts.
python -m pip install pyexcel
Verify Installation Path
Python looks for modules in specific paths. Your pyexcel installation might be elsewhere. Check Python's module search path.
Run this Python code to see paths. It shows where Python searches for modules.
import sys
print(sys.path)
Ensure pyexcel is in one of these paths. If not, there's an installation issue.
Handle Name Conflicts
Sometimes other modules have similar names. This can cause import conflicts. Ensure you're importing the correct package.
Pyexcel has several related packages. Like pyexcel-xls or pyexcel-xlsx. They handle specific file formats.
You might need additional packages. Install them based on your needs. For Excel files, install pyexcel-xls.
pip install pyexcel-xls
Reinstall pyexcel Package
Corrupted installations can cause ImportError. Reinstalling often fixes these issues. It ensures all files are proper.
First uninstall the package. Then install it again fresh. This resolves many common problems.
pip uninstall pyexcel
pip install pyexcel
Use the --force-reinstall flag with pip. This forces a clean installation. It overwrites existing files.
pip install --force-reinstall pyexcel
Check for Typos
Simple typos can cause ImportError. Python module names are case-sensitive. Pyexcel must be spelled correctly.
Check your import statement carefully. Ensure it matches the package name exactly. Even small mistakes matter.
# Correct
import pyexcel
# Incorrect - will cause ImportError
import PyExcel
import py_excel
import pyexel
Complete Working Example
Here's a complete example. It shows proper installation and usage. Follow these steps in order.
# Create and activate virtual environment
python -m venv excel_env
source excel_env/bin/activate
# Install pyexcel and plugins
pip install pyexcel
pip install pyexcel-xls
# Verify installation
python -c "import pyexcel; print('pyexcel imported successfully')"
pyexcel imported successfully
Now create a Python script. Use pyexcel to read an Excel file.
import pyexcel as pe
# Create sample data
data = [['Name', 'Age'], ['John', 30], ['Jane', 25]]
# Save to Excel file
pe.save_as(array=data, dest_file_name="sample.xls")
# Read from Excel file
records = pe.get_records(file_name="sample.xls")
for record in records:
print(record)
{'Name': 'John', 'Age': 30}
{'Name': 'Jane', 'Age': 25}
Conclusion
Fixing ImportError: No module named pyexcel is straightforward. Follow these steps methodically. Start with installation verification.
Use virtual environments consistently. Check Python and pip versions match. Ensure correct spelling in import statements.
Proper environment setup prevents most issues. Our guide on Install pyexcel in Python with pip and Virtualenv helps with this.
Now you can handle this error confidently. Your pyexcel projects will run smoothly. Happy coding with Python and Excel files.