I have downloaded BeautifulSoup using pip3 install beautifulsoup and it worked fine.
But when I try from bs4 import BeautifulSoup or import BeautifulSoup, I get the error ModuleNotFoundError: No module named 'BeautifulSoup' or ModuleNotFoundError: No module named 'bs4' depending on which line of code I use.
I have no idea what's wrong. Why do I get the error?
pip3 install beautifulsoup will install BeautifulSoup older version (Beautiful Soup 3 to be precise).
You need to do pip3 install beautifulsoup4 or pip3 install bs4 to install BeautifulSoup4
and then you can just use it like this :
from bs4 import BeautifulSoup
You can refer to the download page and documentation of Beautiful Soup for more understanding on this.
I had the same problem and what solved it for me was to upgrade pip3.
Try this from this thread comment
pip3 install --upgrade pip
And if that does not work, there is another way to upgrade it that I found from this post
curl https://bootstrap.pypa.io/get-pip.py | python3
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