Indicates an error in the BeautifulSoup code

Bug #1901216 reported by Ainur on 2020-10-23
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Beautiful Soup
Undecided
Unassigned

Bug Description

When I do this:

from bs4 import BeautifulSoup
import urllib.request

req = urllib.request.urlopen('https://www.ua-football.com/sport')
# html = req.read()
print(req)

An error comes out:

Traceback (most recent call last):
  File "C:/pyton/paser.py", line 1, in <module>
    from bs4 import BeautifulSoup
  File "C:\pyton\venv\lib\site-packages\bs4\__init__.py", line 32, in <module>
    from .builder import builder_registry, ParserRejectedMarkup
  File "C:\pyton\venv\lib\site-packages\bs4\builder\__init__.py", line 7, in <module>
    from bs4.element import (
  File "C:\pyton\venv\lib\site-packages\bs4\element.py", line 19, in <module>
    from bs4.formatter import (
  File "C:\pyton\venv\lib\site-packages\bs4\formatter.py", line 1, in <module>
    from bs4.dammit import EntitySubstitution
  File "C:\pyton\venv\lib\site-packages\bs4\dammit.py", line 15, in <module>
    import logging
  File "C:\Python37\lib\logging\__init__.py", line 28, in <module>
    from string import Template
  File "C:\pyton\string.py", line 19
    print(verse1)
                ^
SyntaxError: EOF while scanning triple-quoted string literal

Leonard Richardson (leonardr) wrote :

It looks like you created a file called "string.py" in your root Python directory. That's the file with the syntax error in it. "string" is the name of a standard library in Python. When the "logging" library tries to import that library, it's getting your "string.py" instead.

Rename string.py to something else and the problem should go away.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers