#python报错
摘要:python报错
##python文件路径转义报错
报错代码:
planets = cv2.imread('C:\Users\holmes\Desktop\ARM\image\1.jpg',1)
报错打印:
File "c:\Users\holmes\Desktop\ARM\Ai_FPV\liyangwei.py", line 94
cv2.imwrite('C:\Users\holmes\Desktop\ARM\image\planets_circles.jpg',planets)
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes
in position 2-3: truncated \UXXXXXXXX escape
解决方法:
加上一个转义字符r
planets = cv2.imread(r'C:\Users\holmes\Desktop\ARM\image\1.jpg',1)
##ModuleNotFoundError: No module named 'yaml’报错
报错代码:
import yaml
报错打印:
exe c:/Users/holmes/Desktop/ARM/Ai_FPV/liyangwei.py
Traceback (most recent call last):
File "c:\Users\holmes\Desktop\ARM\Ai_FPV\liyangwei.py", line 4, in <module>
import HiwonderSDK.yaml_handle as yaml_handle
import yaml
ModuleNotFoundError: No module named 'yaml'
解决方法:
pip install update
pip install pyyaml
装好yaml后运行如果报错:ypeError: load() missing 1 required positional argument: 'Loader'
出现这个问题的原因是版本问题,导致一些API被遗弃了
解决方式:卸载之前安装的pyyaml,安装低版本的
pip uninstall pyyaml
pip install pyyaml==5.1
解决方式二:修改代码
yaml.load(file,Loader=yaml.FullLoader)
yaml.safe_load(file)
yaml.load(file, Loader=yaml.CLoader)