Error In python code snippet | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Error In python code snippet

I installed Beautifulsoup4 using pip utility and when i tried to import in a file which i am editing in atom compiler i am getting error please suggest me a way to debug error. code: From bs4 import BeautifulSoup error: Traceback (most recent call last): File "trial.py", line 1, in <module> from bs4 import BeautifulSoup File "C:\Users\Chinmay B S\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\__init__.py", line 31, in <module> from .builder import builder_registry, ParserRejectedMarkup File "C:\Users\Chinmay B S\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\builder\__init__.py", line 7, in <module> from bs4.element import ( File "C:\Users\Chinmay B S\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\element.py", line 19, in <module> from bs4.formatter import ( File "C:\Users\Chinmay B S\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\formatter.py", line 1, in <module> from bs4.dammit import EntitySubstitution File "C:\Users\Chinmay B S\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\dammit.py", line 13, in <module> from html.entities import codepoint2name File "C:\Users\Chinmay B S\Desktop\coursera\html.py", line 6, in <module> from bs4 import BeautifulSoup ImportError: cannot import name 'BeautifulSoup' from partially initialized module 'bs4' (most likely due to a circular import) (C:\Users\Chinmay B S\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\__init__.py)

2nd Jun 2020, 4:20 AM
Chinnmay B S
Chinnmay B S - avatar
1 Answer
+ 5
1. Make sure you used 'pip install beautifulsoup4' and not just 'beautifulsoup' 2. At the end of the error there is 'most likely due to a circular import', so maybe one of the files in your directory uses the same file name as a bs4 module, try running the line from an interpreter in empty directory and see if it gives the same error
2nd Jun 2020, 4:27 AM
Aymane Boukrouh
Aymane Boukrouh - avatar