Python Forum
EOF while scanning triple-quoted string literal
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EOF while scanning triple-quoted string literal
#1
file_name = (r'C:\Users\user\Desktop\ehmatthes-pcc_2e-9e7977b\chapter_10\alice.txt')

with open(file_name) as f_obj:
contents = f_obj.read()


Output: Fatal Python error: initsite: Failed to import the site module
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site.py", line 579, in <module>
main()
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site.py", line 562, in main
known_paths = venv(known_paths)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site.py", line 494, in venv
addsitepackages(known_paths, [sys.prefix])
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site.py", line 159, in addpackage
f = open(fullname, "r")
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\encodings\__init__.py", line 100, in search_function
level=0)
File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\encodings\cp1252.py", line 308

^
SyntaxError: EOF while scanning triple-quoted string literal




Question: pls help, have anyone know what the issues?
Reply
#2
Somewhere you have started a triple-quoted comment and not completed it.

print("start")
"""This is a triple-quoted comment
   oops, I didn't close in properly""
print("end")
Output:
$ python3 quoteit.py File "quoteit.py", line 6 ^ SyntaxError: EOF while scanning triple-quoted string literal
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  email Library: properly send message as quoted-printable malonn 3 1,311 Nov-14-2022, 09:31 PM
Last Post: malonn
  trying to understand a string literal in a basic server program CompleteNewb 4 2,105 Nov-14-2021, 05:33 AM
Last Post: deanhystad
  invalid literal for int() with base 10: '' mrsenorchuck 5 5,428 Apr-29-2020, 05:48 AM
Last Post: markfilan
  Subtract 11 from entire list of quoted numbers Pleiades 1 1,700 Nov-14-2019, 10:26 AM
Last Post: Larz60+
  Help converting MATLAB triple-for loop to Python davlovsky 1 1,983 Oct-29-2019, 10:26 PM
Last Post: scidam
  Syntax Error EOL while scanning string literal intjuma 0 2,484 Jun-28-2019, 01:56 AM
Last Post: intjuma
  using ' inside ''' quoted strings or " inside """ quoted strings Skaperen 2 2,419 Dec-27-2018, 04:37 AM
Last Post: Skaperen
  Do I always have to use triple quotes or \n for multi-line statements? DragonG 3 2,604 Oct-24-2018, 11:21 AM
Last Post: metulburr
  splitting a line with quoted whiespace Skaperen 1 2,269 Sep-01-2018, 04:16 AM
Last Post: buran
  SyntaxError: EOL while scanning string literal on with open() statement Regulus 3 7,342 Feb-23-2018, 06:40 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020