繁体   English   中英

Pyserial:无法配置端口:(5,'输入/输出错误)

[英]Pyserial: could not configure port: (5, 'Input/output error)

我一直试图在过去的两天里运行以下两行Python代码,但没有取得多大成功:

import serial
ser = serial.Serial(0)

每次运行它,我都会收到以下错误:

Traceback (most recent call last):
  File "./test.py", line 4, in <module>
    ser = serial.Serial(0)
  File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in __init__
    self.open()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 280, in open
    self._reconfigurePort()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 308, in _reconfigurePort
    raise SerialException("Could not configure port: %s" % msg)
serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')

我正在运行Ubuntu 11.10 64位,Pyserial 2.5(python-serial 2.5-2.1)和Python 2.7(python 2.7.2-7ubuntu2),我的用户是拨出组的成员。

我也在运行Ubuntu 11.10 64位,使用相同版本的Python和Pyserial,并且似乎没有出现问题。 欢迎任何建议 - 我很沮丧......

谢谢,多纳

如果端口不可用,则抛出此异常。 在Linux上,您只需指定要使用的端口的确切名称,例如

ser = serial.Serial('/dev/ttyACM0')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM