调用指令,
pip pyserial install
安装最新版本的pyserial,程序运行时提示错误如下,
File "C:\Python27\lib\site-packages\serial\__init__.py", line 27, in
from serial.serialwin32 import Serial
File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 15, in
from serial import win32
File "C:\Python27\lib\site-packages\serial\win32.py", line 182, in
CancelIoEx = _stdcall_libraries['kernel32'].CancelIoEx
File "C:\Python27\lib\ctypes\__init__.py", line 375, in __getattr__
func = self.__getitem__(name)
File "C:\Python27\lib\ctypes\__init__.py", line 380, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'CancelIoEx' not found
原因CancelIoEx函数,只在Vista及以上版本运行。
解决方法
下载低版本的pyserial,尝试是否兼容xp环境。
下载安装pyserial-3.0版本成功解决此问题。
pyserial-3.0下载地址
官方下载地址