How Do You Troubleshoot the Python Problem “SyntaxError: EOL while scanning string literal”?

Problem scenario
You are running a Python program or trying to execute a line from the Python interpreter command line. You receive this message: "SyntaxError: EOL while scanning string literal". What should you do?

Look for the double quotes and single quotes. Have they all be terminated? Are they in an even number? Was the code copied to a different workstation application and then pasted into vi or a terminal prompt? Sometimes when you paste code in MacOS or Windows, the single or double quotes become angled. Rather than have uniform courier font in a terminal, other angled quotes are possible. To learn more about italicized quotes "“”‘’" (which can be hard to see and/or detect), you can view this posting.

Leave a comment

Your email address will not be published. Required fields are marked *