Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import BeautifulSoup

To my understanding "import package.module" is same as "from package import module". But this is not behaving as expected in case of BeautifulSoup.

from bs4 import BeautifulSoup: This command works fine.

But,

import bs4.BeautifulSoup throws the following error

ModuleNotFoundError: No module named 'bs4.BeautifulSoup'

Any thoughts/help on this?

like image 986
Srikanta Patra Avatar asked Oct 24 '25 14:10

Srikanta Patra


1 Answers

As colorspeed pointed out above, BeautifulSoup is a class therefore import bs4.BeautifulSoup will result in error. Instead use the syntax from bs4 import BeautifulSoup.

like image 84
Daniel Avatar answered Oct 26 '25 04:10

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!