萤石-module 'serial' has no attribute 'Serial'

module 'serial' has no attribute 'Serial'

问题代码:

1 import serial #导入pyserial
2 com = serial.Serial('com3' , 115200) #实例化串口,com3,波特率115200

报错:module 'serial' has no attribute 'Serial'

解决方法:1、卸载serial;2、卸载pyserial;3、重新打开编辑器。

1 pip uninstall serial
2 pip uninstall pyserial
3 pip install pyserial

 

posted @ 2021-06-10 12:47  司砚章  阅读(318)  评论(0编辑  收藏  举报