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:
- [Solved] yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
- [Solved] Training yolov5 Error: attributeerror: can get attribute sppf on Module
- [Solved] YOLOv5 Model training error: TypeError: new(): invalid data type ‘str’
- [Solved] Yolov5 Deep Learning Error: RuntimeError: DataLoader worker (pid(s) 2516, 1768) exited unexpectedly
- Python Error: ValueError: invalid literal for int() with base 16: ‘ ‘
- [Solved] SyntaxError: (unicode error) ‘utf-8’ codec can’t decode byte 0xbe in position 0
- [Solved] SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 6-7: malformed
- [Solved] SyntaxError: Non-UTF-8 code starting with ‘\xe6‘ in file
- [Solved] YOLOv4 Error: Layer before convolutional layer must output image.: No error
- [Solved] SyntaxError: Generator expression must be parenthesized
- SyntaxError: Non-UTF-8 code starting with ‘\xe4‘ in file [How to Solve Chinese encoding problem]
- Syntaxerror: unexpected EOF while parsing solution and ideas
- SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UX
- Python Error: SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 2-3:
- SyntaxError: Non-ASCII character ‘\xe5‘ in file [How to Solve]
- Python Error: SyntaxError: ‘break‘ outside loop
- [Solved] SyntaxError: Generator expression must be parenthesized (widgets.py, line 152)
- [Solved] Python operate Kafka error: SyntaxError: invalid syntax
- [Solved] sys.stderr.write(f“ERROR: {exc}“) ^ SyntaxError: invalid syntax
- [Solved] SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 10-11: malformed