简体   繁体   English

当我尝试运行此Python程序时,出现回溯错误(最近一次调用最近)。 我想知道解决方案

[英]I get an error of traceback (most recent call last) when I try to run this Python program. I want to know the solution to this

This is a Python program to receive the data from an XBee module using the python-xBee library. 这是一个Python程序,它使用python-xBee库从XBee模块接收数据。 I have installed both the xbee and pyserial modules. 我已经安装了xbeepyserial模块。

import serial
from xbee import XBee

serial_port = serial.Serial('/dev/ttyUSB0', 9600)
xbee = XBee(serial_port)

while True:
try:
    print xbee.wait_read_frame()
except KeyboardInterrupt:
   break

serial_port.close()

But when I run this and any kind of program with serial port, this is the error I am getting: 但是,当我运行此程序以及任何带有串行端口的程序时,这是我得到的错误:

Traceback (most recent call last):
  File "C:/Users/Manurajeev/PycharmProjects/untitled/one.py", line 4, in
<module>
    serial_port = serial.Serial('/dev/ttyUSB0', 9600)
  File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 31, in
__init__
    super(Serial, self).__init__(*args, **kwargs)
  File "C:\Python27\lib\site-packages\serial\serialutil.py", line 240, in
__init__
    self.open()
  File "C:\Python27\lib\site-packages\serial\serialwin32.py", line 62, in
open
    raise SerialException("could not open port {!r}:
{!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port '/dev/ttyUSB0':
WindowsError(3, 'The system cannot find the path specified.')

Process finished with exit code 1

I don't understand what the problem is. 我不明白问题是什么。 I tried everything, but the same error keeps popping up every time. 我尝试了所有操作,但是每次都会出现相同的错误。

In Linux, check the permissions on the tty device ( ls -l /dev/ttyUSB0 ) to ensure that you have read/write access to it. 在Linux中,检查tty设备( ls -l /dev/ttyUSB0 )的权限,以确保您具有对该设备的读/写访问权限。 Note that it might have a different name. 请注意,它可能具有不同的名称。

For Windows, have you been able to open COM5 with a terminal emulator and send/receive data on the XBee? 对于Windows,您是否能够使用终端仿真器打开COM5并在XBee上发送/接收数据? Do you still have it open in another program when you're trying to open it in Python? 当您尝试在Python中打开它时,还在其他程序中打开它吗? Only one program can access a COM port at a time. 一次只能有一个程序可以访问COM端口。

暂无
暂无

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

相关问题 每次运行此代码时,我都会得到 Traceback(最近一次调用),如何解决这个问题? - I get Traceback (most recent call last) each time I run this code, how to fix this? 为什么我会收到“回溯(最近一次呼叫最后一次):”错误? - Why am I getting a “ Traceback (most recent call last):” error? 我如何摆脱这个错误:Traceback(最近一次调用最后一次):文件“<string> ",第 1 行,在<module>文件“C:\程序?</module></string> - How Do I get rid of this error:Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program? 我在以下程序中遇到错误,因为 KeyError Traceback(最近一次调用最后一次) - I'm getting an error in the following program as KeyError Traceback (most recent call last) 我正在获取 Traceback Traceback(最近一次通话最后一次): - i am getting Traceback Traceback (most recent call last): Traceback(最近一次通话最后一次)Python 错误 - Traceback (most recent call last) Python Error Python 错误回溯(最后一次调用): - Python Error Traceback (most recent call last): Python追踪(最近一次通话)错误 - Python Traceback (most recent call last) error 我为什么要得到回溯(最近一次通话是最近一次): - Why am I getting a Traceback (most recent call last): 当我启动这段代码时,我在 pygame 模块的代码中发现了错误 Traceback (last last call last) 的问题 - When I start this code, i found a problem with error Traceback (most recent call last) in my code with pygame module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM