The “modulenotfounderror: no module named bs4” error occurs when you try to import the “bs4” module in Python.
Yet the python interpreter cannot find the installed “bs4” module on your system.
The “bs4” is an abbreviation for “BeautifulSoup4“. Moreover, the ‘bs4‘ is a Python library which is used for web scraping, parsing HTML and XML documents.
To solve this error, you need to install the “bs4” module.
Also read the other solved error: Modulenotfounderror: no module named ‘google’ [SOLVED]
Why the modulenotfounderror: no module named ‘bs4’ error occur?
The modulenotfounderror: no module named ‘bs4’ error occur because you might able to forget to install the beautifulsoup4 module before you import it.
You might installed the beautifulsoup4 in an incorrect environment variable.
Common Error Occurs
There can be several reasons why you might encounter the “ModuleNotFoundError: No module named ‘bs4′” error. Here are a few common reasons:
- Missing Installation:
- Incorrect Module Name:
- Incorrect Python Version:
- Virtual Environment:
- Path Issues:
- Corrupted Installation:
- Incorrect Spelling:
How to solved the modulenotfounderror no module named ‘bs4’?
You can install “bs4” using pip command, which is a package manager for Python language.
Time needed: 3 minutes
Here are the solutions to solve the error modulenotfounderror no module named bs4 in a different operating system platform.
- Solution 1: Installation of
beautifulsoup4in PythonIn your project folder root directory, Open your terminal windows or command prompt(CMD) and enter the following command to install the bs4 in Python:
pip install beautifulsoup4
After you run the following command above it will successfully install the bs4 in python![pip install bs4 in Modulenotfounderror no module named bs4 [SOLVED]](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNzc5IiBoZWlnaHQ9IjE3NCIgdmlld0JveD0iMCAwIDE3NzkgMTc0Ij48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBzdHlsZT0iZmlsbDojY2ZkNGRiO2ZpbGwtb3BhY2l0eTogMC4xOyIvPjwvc3ZnPg==)
After you install the beautifulsoup4 module in windows, you may try to import it with the following code below:from bs4 import BeautifulSoup
soup = BeautifulSoup("<p>Some<b>bad<i>HTML")
print(soup.prettify()) - Solution 2: Installation of
beautifulsoup4in Python 3In your project folder root directory, Open your terminal windows or command prompt(CMD) and enter the following command to install the
in Python 3:beautifulsoup4pip3 install beautifulsoup4
After you execute the command above it will successfully install thebs4in python 3:![pip install bs4 python 3 in Modulenotfounderror no module named bs4 [SOLVED]](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxODM0IiBoZWlnaHQ9IjE3MiIgdmlld0JveD0iMCAwIDE4MzQgMTcyIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBzdHlsZT0iZmlsbDojY2ZkNGRiO2ZpbGwtb3BhY2l0eTogMC4xOyIvPjwvc3ZnPg==)
- Solution 3: Installation of
beautifulsoup4in Server SideWhen you are getting an error in your server side. In your project folder root directory, Open your terminal windows or command prompt(CMD) and enter the following command for Installation of
beautifulsoup4in Server Side.
For Linux:sudo pip3 install beautifulsoup4
For Windows:pip install beautifulsoup4 --user
After you run the command above it will successfully install thebs4in python 3 on windows:![pip install bs4 for windows in Modulenotfounderror no module named bs4 [SOLVED]](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxODA5IiBoZWlnaHQ9IjE4MSIgdmlld0JveD0iMCAwIDE4MDkgMTgxIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBzdHlsZT0iZmlsbDojY2ZkNGRiO2ZpbGwtb3BhY2l0eTogMC4xOyIvPjwvc3ZnPg==)
- Solution 4: Installation of pip in your PATH environment variable in Python 2
If you don’t have pip install in your PATH environment variable. Type the following command below to install the pip and bs4 in your path environment.
python -m pip install beautifulsoup4
After you run the command above it will successfully install the pip andbs4in your path environment variable:![pip bs4 for windows in Modulenotfounderror no module named bs4 [SOLVED]](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNzkwIiBoZWlnaHQ9IjE3NSIgdmlld0JveD0iMCAwIDE3OTAgMTc1Ij48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBzdHlsZT0iZmlsbDojY2ZkNGRiO2ZpbGwtb3BhY2l0eTogMC4xOyIvPjwvc3ZnPg==)
Installation of pip in your PATH environment variable in Python 3
If you don’t have pip install in your PATH environment variable in your python 3. Type the following command below to install the pip and bs4 in your path environment.python3 -m pip install beautifulsoup4 - Solution 5: Installation of
beautifulsoup4in py alias
In your project folder root directory, Open your terminal windows or command prompt(CMD) and enter the following command to install the beautifulsoup4 in Py Alias:py -m pip install beautifulsoup4
After you execute the command above it will successfully install the bs4 in py alias:![py bs4 install in Modulenotfounderror no module named bs4 [SOLVED]](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxODA4IiBoZWlnaHQ9IjE3NyIgdmlld0JveD0iMCAwIDE4MDggMTc3Ij48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBzdHlsZT0iZmlsbDojY2ZkNGRiO2ZpbGwtb3BhY2l0eTogMC4xOyIvPjwvc3ZnPg==)
- Solution 6: Installation of
beautifulsoup4in Ubuntu/DebianHere is the following command to install the beautifulsoup4 in Ubuntu/Debian:
sudo apt-get install python3-bs4 - Solution 7: Installation of
beautifulsoup4in AnacondaIn your project folder root directory, Open your terminal or anaconda command prompt(CMD) and enter the following command for Installation of beautifulsoup4 in Anaconda.
conda install -c anaconda beautifulsoup4![anaconda bs4 install in Modulenotfounderror no module named bs4 [SOLVED]](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNDg0IiBoZWlnaHQ9IjEwMDMiIHZpZXdCb3g9IjAgMCAxNDg0IDEwMDMiPjxyZWN0IHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHN0eWxlPSJmaWxsOiNjZmQ0ZGI7ZmlsbC1vcGFjaXR5OiAwLjE7Ii8+PC9zdmc+)
- Solution 8: Installation of
beautifulsoup4in Jupyter NotebookHere is the following command to install the beautifulsoup4 in Jupyter Notebook:
!pip install bs4![jupyter notebook bs4 install in Modulenotfounderror no module named bs4 [SOLVED]](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNDY4IiBoZWlnaHQ9IjQ4NSIgdmlld0JveD0iMCAwIDE0NjggNDg1Ij48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBzdHlsZT0iZmlsbDojY2ZkNGRiO2ZpbGwtb3BhY2l0eTogMC4xOyIvPjwvc3ZnPg==)
Frequently Asked Questions
What is Python ModuleNotFoundError and what causes it?
ModuleNotFoundError (a subclass of ImportError) is raised when Python cannot find the module you tried to import. Common causes: the package isn’t installed (pip install missing), wrong virtual environment activated, typo in module name, or Python can’t find your local module on the import path. The error message names exactly which module is missing.
How do I fix ‘ModuleNotFoundError: No module named X’?
Run pip install X first. If that succeeds but you still get the error, check which Python you’re using (which python OR python –version) vs which pip (which pip OR pip –version), they must match. Common gotcha: pip points to system Python 3.9 but you’re running python3.11 in a venv. Inside the venv, use python -m pip install X to be sure pip matches the active Python.
Why does my code work in one environment but not another?
Different Python versions or different installed packages. To diagnose: pip freeze > requirements.txt on the working environment, then pip install -r requirements.txt on the broken one. Use virtualenv (python -m venv venv) or conda for every project to avoid system-wide package collisions.
Is ModuleNotFoundError the same as ImportError?
ModuleNotFoundError is a subclass of ImportError added in Python 3.6. It specifically means ‘no such module exists.’ Plain ImportError covers a wider set: module exists but a name inside it can’t be imported (e.g. ‘cannot import name X from Y’). except ImportError catches both; except ModuleNotFoundError catches only the missing-module case.
Where can I find more ModuleNotFoundError fixes?
Browse the ModuleNotFoundError reference hub for 198+ specific module fixes (TensorFlow, Flask, Django, pandas, numpy, etc.). For related issues see ImportError. For broader Python setup see Python Tutorial hub.
Conclusion
That’s it! You should now be able to use the bs4 module in your Python projects. The above solutions can help you to solve the error Modulenotfounderror: no module named bs4 on a different operating system, you’re being used.

![pip install bs4 in Modulenotfounderror no module named bs4 [SOLVED]](https://itsourcecode.com/wp-content/uploads/2023/03/pip-install-bs4-in-Modulenotfounderror-no-module-named-bs4-SOLVED.png)
![pip install bs4 python 3 in Modulenotfounderror no module named bs4 [SOLVED]](https://itsourcecode.com/wp-content/uploads/2023/03/pip-install-bs4-python-3-in-Modulenotfounderror-no-module-named-bs4-SOLVED.png)
![pip install bs4 for windows in Modulenotfounderror no module named bs4 [SOLVED]](https://itsourcecode.com/wp-content/uploads/2023/03/pip-install-bs4-for-windows-in-Modulenotfounderror-no-module-named-bs4-SOLVED.png)
![pip bs4 for windows in Modulenotfounderror no module named bs4 [SOLVED]](https://itsourcecode.com/wp-content/uploads/2023/03/pip-bs4-for-windows-in-Modulenotfounderror-no-module-named-bs4-SOLVED.png)
![py bs4 install in Modulenotfounderror no module named bs4 [SOLVED]](https://itsourcecode.com/wp-content/uploads/2023/03/py-bs4-install-in-Modulenotfounderror-no-module-named-bs4-SOLVED.png)
![anaconda bs4 install in Modulenotfounderror no module named bs4 [SOLVED]](https://itsourcecode.com/wp-content/uploads/2023/03/anaconda-bs4-install-in-Modulenotfounderror-no-module-named-bs4-SOLVED.png)
![jupyter notebook bs4 install in Modulenotfounderror no module named bs4 [SOLVED]](https://itsourcecode.com/wp-content/uploads/2023/03/jupyter-notebook-bs4-install-in-Modulenotfounderror-no-module-named-bs4-SOLVED.png)