Pyserial:无法配置端口:(5,'输入/输出错误) [英] Pyserial: could not configure port: (5, 'Input/output error)
问题描述
在过去的两天里,我一直试图让以下两行Python代码运行,但收效甚微:
I've been trying to get the following two lines of Python code to run for the past two days, without much success:
import serial
ser = serial.Serial(0)
每次运行它时,都会出现以下错误:
Each time I run it, I get the following error:
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')
我正在运行带有Pyserial 2.5(python-serial 2.5-2.1)和Python 2.7(python 2.7.2-7ubuntu2)的64位Ubuntu 11.10,我的用户是拨出组的成员.
I'm running Ubuntu 11.10 64-bit, with Pyserial 2.5 (python-serial 2.5-2.1) and Python 2.7 (python 2.7.2-7ubuntu2) and my user is a member of the dialout group.
我也在工作时使用相同版本的Python和Pyserial运行64位Ubuntu 11.10,并且该问题似乎没有发生.任何建议都欢迎-我很困惑...
I run Ubuntu 11.10 64-bit at work too, with the same versions of Python and Pyserial, and the problem doesn't seem to occur there. Any suggestions are welcome - I'm pretty flummoxed...
谢谢,多纳(Donagh)
Thanks, Donagh
推荐答案
如果端口不可用,则抛出此异常.在Linux上,您只需指定要使用的端口的确切名称即可,例如
This exception is thrown if the port is not available. On Linux, you can simply specify the exact name of the port to use, like
ser = serial.Serial('/dev/ttyACM0')
这篇关于Pyserial:无法配置端口:(5,'输入/输出错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!