Asad Ali
Asad Ali

Reputation: 23

BeautifulSoup not working in google colab

I have tried the below code in google colab but it gives an error which i have also shown below

!pip install beautifulsoup4

Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.7/dist-packages (4.6.3)

from beautifulsoup4 import BeautifulSoup

ModuleNotFoundError Traceback (most recent call last) in () ----> 1 from beautifulsoup4 import BeautifulSoup

ModuleNotFoundError: No module named 'beautifulsoup4'

--------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the "Open Examples" button below.


Than i also tried

!apt install BeautifulSoup4

E: Unable to locate package BeautifulSoup4

!apt install BeautifulSoup

E: Unable to locate package BeautifulSoup

I have also tried the above commands without exclamation mark (!). other packages were installed but beautifulsoup4 is not installing neither it is allowing to import.

I appreciate if someone can guide me regarding this.

Upvotes: 1

Views: 10473

Answers (3)

Hashini Senthil
Hashini Senthil

Reputation: 31

Instead of

from beautifulsoup4 import BeautifulSoup

Try out

from bs4 import BeautifulSoup

Upvotes: 3

leallopes
leallopes

Reputation: 1

! pip install bs4

It worked very well in Google colaboratory.

Upvotes: 0

Vova
Vova

Reputation: 3547

for importing BeautifulSoup use that one:

from bs4 import BeautifulSoup

there's usual case a different package naming while installing and the step of importing/using

Upvotes: 5

Related Questions