'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.



Solution 1:[1]

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

Solution 2:[2]

Instead of

from beautifulsoup4 import BeautifulSoup

Try out

from bs4 import BeautifulSoup

Solution 3:[3]

! pip install bs4

It worked very well in Google colaboratory.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Vova
Solution 2 pppery
Solution 3 Amal K