If you enter the following code in IDLE, an error? will be displayed.Could you tell me the solution?
from bs4 import BeautifulSoup
soup = BeautifulSoup(html.centent, "html.parser")
Error?
Traceback (most recent call last):
File"/Users/user name/Documents/20210114.py", line 1, in <module>
from bs4 import BeautifulSoup
File"/Library/Frameworks/Python.frameworks/Version/3.9/lib/python 3.9/site-packages/bs4/_init___.py", line 32, in <module>
from.builder import builder_registry, ParserRejectedMarkup
File"/Library/Frameworks/Python.frameworks/Version/3.9/lib/python 3.9/site-packages/bs4/builder/__init__.py", line 7, in<module>
from bs4.element import(
File"/Library/Frameworks/Python.framework/Version/3.9/lib/python 3.9/site-packages/bs4/element.py", line 19, in <module>
from bs4.formatter import(
File"/Library/Frameworks/Python.framework/Version/3.9/lib/python 3.9/site-packages/bs4/formatter.py", line 1, in <module>
from bs4.dammit import EntitySubstitution
File"/Library/Frameworks/Python.framework/Version/3.9/lib/python 3.9/site-packages/bs4/dammit.py", line 13, in <module>
from html.entities import codepoint2name
File"/Users/user name/Documents/html.py", line2, in<module>
from bs4 import BeautifulSoup
ImportError: cannot import name 'BeautifulSoup' from partially initialized module 'bs4' (most like due to a circular import) (/Library/Frameworks/Python.Frameworks/Versions/3.9/lib/python 3.9/site-packages/in___)
What is the cause of Try changing the Similarly, it is recommended that you stop naming script files or unique class/method/variable names that are likely to be used in Python libraries/packages/modules.File"/Users/user name/Documents/html.py", line 2, in from bs4 import BeautifulSoup
at the end of the error message? html
module?, instead of html.py
because html
that you are trying to run exists in the same folder as File"/Users/user name/Documents/20210114.py", line1, in from bs4import BeautifulSoup
, you want to use instead of
html
html.py
in /Users/user name/Documents/
to a different name or move to a location that is not included in Python's module search path.
© 2024 OneMinuteCode. All rights reserved.