Answer a question

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.

Answers

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

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐