[Solved] YOLOv5 Error: SyntaxError: EOL while scanning string literal

1. Error details

When running the detect.py file of YOLOv5 module, the following error occurs:

Complete error reporting code:

  File "C:\Projects\pythonProject\yolov5-5.0\detect.py", line 110
    with open(txt_path + '.txt', 'a') as f:
                                           ^
SyntaxError: EOL while scanning string literal

This problem occurs because detect.py encoding error

2.Solution

Delete the two lines of code at the top of the file, and the problem can be solved and detected.

# -*- coding : utf-8-*-
# coding:unicode_escape

Read More: