er@er:~/Desktop$ /usr/bin/env /bin/python /home/er/.vscode/extensions/ms-python.python-2022.16.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher 45473 -- /home/er/Desktop/JZD Traceback (most recent call last): File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 265, in open self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK) FileNotFoundError: [Errno 2] No such file or directory: 'COM3' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/er/Desktop/JZD", line 24, in <module> mc = MyCobot("COM3", 115200) File "/usr/local/lib/python3.8/dist-packages/pymycobot/mycobot.py", line 64, in __init__ self._serial_port.open() File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 268, in open raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg)) serial.serialutil.SerialException: [Errno 2] could not open port COM3: [Errno 2] No such file or directory: 'COM3' er@er:~/Desktop$
时间: 2023-09-08 16:16:56 浏览: 273
这个错误是由于在打开串口 'COM3' 时出现了问题。'COM3' 是 Windows 操作系统中的串口设备名称,而你的代码在 Linux 环境下运行,因此找不到该设备。你需要将代码中的串口设备名称更改为适用于 Linux 的设备名称。你可以通过 `ls /dev/tty*` 命令查看可用的串口设备列表,并选择适合你的设备名称。例如,如果你的设备名称是 '/dev/ttyUSB0',你可以将代码中的 "COM3" 替换为 "/dev/ttyUSB0"。这样应该可以解决问题。
阅读全文