编程语言
首页 > 编程语言> > Python串行导入时出错

Python串行导入时出错

作者:互联网

当我尝试导入序列时,我收到以下错误:

Traceback (most recent call last):
  File "C:\Documents and Settings\eduardo.pereira\workspace\thgspeak\tst.py", line 7, in <module>
    import serial
  File "C:\Python27\lib\site-packages\serial\__init__.py", line 27, in <module>
    from serial.serialwin32 import Serial
  File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 15, in <module>
    from serial import win32
  File "C:\Python27\lib\site-packages\serial\win32.py", line 182, in <module>
    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

我在WinXP笔记本电脑上安装了最新版本的pySerial,Python 2.7.到处尝试,发现没有类似的问题.那有什么解决方案吗?
提前致谢…

解决方法:

您正在使用的pySerial版本试图调用仅在Windows Vista中可用的function,而您正在运行Windows XP.

可能值得尝试使用旧版本的pySerial.

有问题的代码是added to pySerial on 3 May 2016,所以之前的版本可能是一个好的开始.

标签:pyserial,python
来源: https://codeday.me/bug/20190727/1554579.html