Tag Archives: Yolov5 Error

[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

How to Solve Yolov5 Common Error (Three Errors)

1. detect.py run error: IndexError: list index out of range Reason: Path error
Solution: Add r in front of the path
before the path

2.subprocess.CalledProcessError: Command ‘git tag‘ returned non-zero exit status

Solution: open the python environment and find the subprocess.py in Lib, change the check value to False in line 415.

My path is D:\Miniconda3\envs\pytorch\Lib

3.UnicodeDecodeError: ‘utf-8‘ codec can‘t decode byte 0xb2 in position 6:invalidstartbyte

Solution: in line 58 of the torch_utils.py file, modify the original decode() to decode(encoding = ‘gbk’)