The Python "ModuleNotFoundError: No module named 'bs4'" occurs when we forget to install the beautifulsoup4 module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install beautifulsoup4 command.
To install Beautifulsoup on Windows, Linux, or any operating system, one would need pip package. To check how to install pip on your operating system, check out – PIP Installation – Windows || Linux. Wait and relax, Beautifulsoup would be installed shortly.
Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work.
Activate the virtualenv, and then install BeautifulSoup4:
$ pip install BeautifulSoup4
When you installed bs4
with easy_install
, you installed it system-wide. So your system python can import it, but not your virtualenv python.
If you do not need bs4
to be installed in your system python path, uninstall it and keep it in your virtualenv.
For more information about virtualenvs, read this
For python2.x:
sudo pip install BeautifulSoup4
For python3:
sudo apt-get install python3-bs4
Just tagging onto Balthazar's answer. Running
pip install BeautifulSoup4
did not work for me. Instead use
pip install beautifulsoup4
Try this:
sudo python3 -m pip install bs4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With