Last modified: Aug 11, 2026
Fix ModuleNotFoundError: notebook.nbextensions
Encountering a ModuleNotFoundError can be frustrating, especially when you are in the middle of a project. This specific error, No module named 'notebook.nbextensions', often appears when using Jupyter Notebook extensions or certain data science libraries.
This guide explains why this happens. More importantly, it shows you how to fix it quickly. We will cover simple solutions and advanced troubleshooting steps.
Why Does This Error Occur?
The error means Python cannot find the nbextensions module inside the notebook package. This usually happens due to a version mismatch or a broken installation.
Jupyter Notebook recently changed its structure. Some libraries, like jupyter_contrib_nbextensions, expect an older version of the notebook package. When you upgrade Jupyter, the path to this module changes, causing the error.
Another common cause is a corrupted environment. This can happen after a partial update or when using multiple Python environments without proper activation.
Quick Fix: Upgrade or Reinstall
The fastest solution is to upgrade the notebook package. This ensures you have the latest compatible version. Open your terminal or command prompt and run the following command.
pip install --upgrade notebook
If you use conda, use this command instead.
conda update notebook
After upgrading, restart your kernel and try again. This solves the issue for most users. If the error persists, move to the next solution.
Solution 1: Install the Missing Extension Package
Sometimes, the issue is not with the notebook itself but with a missing extension package. The error often occurs when you try to use nbextensions without having the contrib package installed.
Install the jupyter_contrib_nbextensions package. This provides the missing module and many useful features.
pip install jupyter_contrib_nbextensions
After installation, enable the extensions with this command.
jupyter contrib nbextension install --user
Now, restart Jupyter Notebook. The error should be gone. This is the most common fix for this specific error.
Solution 2: Use a Virtual Environment
Mixing packages from different projects can cause conflicts. A virtual environment isolates your dependencies. This prevents version clashes and keeps your system clean.
Create a new virtual environment and install Jupyter inside it.
# Create a virtual environment
python -m venv myenv
# Activate it (Windows)
myenv\Scripts\activate
# Activate it (Mac/Linux)
source myenv/bin/activate
# Install Jupyter and the extension
pip install jupyter notebook jupyter_contrib_nbextensions
This approach ensures all packages are compatible. It is a best practice for any Python project. If you want to learn more about managing Python environments, check out our guide on Python Environment Best Practices.
Solution 3: Check Your Jupyter Path
Sometimes, the error occurs because Jupyter is looking in the wrong directory. This can happen if you have multiple Python installations.
First, check where Jupyter is installed.
which jupyter
Then, check the Python path inside your notebook. Run this code in a notebook cell.
import sys
print(sys.executable)
Compare the two paths. They should point to the same environment. If they do not, you have a path mismatch. You need to install Jupyter in the same environment you are using.
# Force install to the correct Python
python -m pip install --upgrade notebook jupyter_contrib_nbextensions
This command explicitly uses your current Python interpreter. It ensures the packages go to the right place. This is a reliable way to fix path-related issues.
Solution 4: Downgrade the Notebook Package
If the latest version is causing problems, you can downgrade. Some extensions are not yet compatible with the newest Jupyter Notebook 7. If you rely on these extensions, downgrading is a practical solution.
First, uninstall the current version. Then, install a stable older version.
pip uninstall notebook -y
pip install "notebook==6.5.7"
This version is known to work well with most extensions. After downgrading, restart Jupyter and test your code. This trade-off is acceptable if you need specific extensions for your workflow.
For more complex debugging, you might want to look at Common Jupyter Kernel Errors to understand related issues.
Solution 5: Clear Jupyter Cache
A corrupted cache can also cause import errors. Clearing the Jupyter cache is a safe and effective step. It removes temporary files that might be conflicting.
Run these commands to clear the cache.
jupyter notebook --clear-cache
jupyter kernelspec list
The first command clears the notebook cache. The second lists your kernels. If you see any broken kernels, you can remove them with jupyter kernelspec remove <kernel_name>. Then, restart Jupyter.
This often resolves strange import errors. It is a good step to try before a full reinstall.
Code Example: Reproducing the Error
Let's see what the error looks like. This helps you identify the exact problem. Try running this code in a Python script or notebook cell.
# This import will fail if the module is missing
from notebook.nbextensions import install_nbextension
print("Import successful")
If the module is missing, you will see this output.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-xxxx> in <module>
----> 1 from notebook.nbextensions import install_nbextension
ModuleNotFoundError: No module named 'notebook.nbextensions'
This confirms the issue. Now you know exactly what to fix. Use the solutions above to resolve it.
Preventing Future Issues
To avoid this error in the future, follow these simple rules. Always use a virtual environment for your projects. This keeps dependencies isolated.
Also, avoid mixing pip and conda for the same package. Choose one package manager and stick with it. This prevents conflicts.
Regularly update your packages with pip list --outdated to see what needs attention. But be careful with major version upgrades. Read the release notes before upgrading Jupyter.
If you are working with data science libraries, check out our Guide to Data Science Setup for a smooth experience.
Conclusion
The ModuleNotFoundError: No module named 'notebook.nbextensions' is a common but solvable issue. It usually points to a version mismatch or missing package. Start with the quick fix of upgrading the notebook package.
If that fails, install jupyter_contrib_nbextensions. For persistent issues, use a virtual environment or check your Python paths. Downgrading the notebook package is also a valid option if you need older extensions.
Always test your setup after each fix. Remember to restart your kernel and clear the cache. With these steps, you can resolve this error and get back to your work. Happy coding!