elmuscovado
elmuscovado

Reputation: 114

Import error with BeautifulSoup

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?

Upvotes: 3

Views: 18264

Answers (2)

Katariina Kari
Katariina Kari

Reputation: 21

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

Upvotes: 1

Satish Prakash Garg
Satish Prakash Garg

Reputation: 2233

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.

Upvotes: 8

Related Questions