Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BeautifulSoup not working cannot import name 'BeautifulSoup' from partially initialized module 'bs4'

I keep getting error code: from bs4 import BeautifulSoup ImportError: cannot import name 'BeautifulSoup' from partially initialized module 'bs4' (most likely due to a circular import) Can not find solution anywhere please help

import requests
from bs4 import BeautifulSoup

source = requests.get('https://www.instagram.com/wedding.pages/followers/').text

soup = BeautifulSoup(source, 'lxml')

print(soup.prettify())
from bs4 import BeautifulSoup
ImportError: cannot import name 'BeautifulSoup' from partially initialized module 'bs4' (most likely due to a circular import)
like image 902
James Shaw Avatar asked Dec 08 '19 16:12

James Shaw


People also ask

What is from BS4 import BeautifulSoup?

Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work.

Is BS4 same as BeautifulSoup?

As BeautifulSoup is not a standard python library, we need to install it first. We are going to install the BeautifulSoup 4 library (also known as BS4), which is the latest one.

What does BeautifulSoup Select Return?

BeautifulSoup has a . select() method which uses the SoupSieve package to run a CSS selector against a parsed document and return all the matching elements.


1 Answers

Try renaming python file that you working on from bs4 to something else. Maybe you named some other file in same directory ps4 so you must change it !

like image 196
user13292922 Avatar answered Nov 01 '22 10:11

user13292922