problem
I have installed the serial and pyserial libraries, but the running code still reports errors.
Check whether it is installed and found that there is no problem.
Solution
Uninstall both libraries and install only pyserial.
pip uninstall serial
pip uninstall pyserial
pip install pyserial
Run the code again, the problem is solved:
Reference article: