module ‘serial’ has no attribute ‘Serial’

问题代码:

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

报错:module ‘serial’ has no attribute ‘Serial’
解决办法:
1、卸载serial;
2、卸载pyserial;
3、重新打开你的编辑器。

pip uninstall serial
pip uninstall pyserial
pip install pyserial

转载来源

猜你喜欢

转载自blog.csdn.net/weixin_47289438/article/details/110781342