serial serialutil SerialException could not open port 'COM1

1、错误描述

 

>>> import serial;
>>> t=serial.Serial
>>> t=serial.Serial("COM1",4800);
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    t=serial.Serial("COM1",4800);
  File "D:\Python\Python36\lib\site-packages\pyserial-3.3-py3.6.egg\serial\serialwin32.py", line 31, in __init__
    super(Serial, self).__init__(*args, **kwargs)
  File "D:\Python\Python36\lib\site-packages\pyserial-3.3-py3.6.egg\serial\serialutil.py", line 240, in __init__
    self.open()
  File "D:\Python\Python36\lib\site-packages\pyserial-3.3-py3.6.egg\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 'COM1': PermissionError(13, '拒绝访问。', None, 5)

2、错误原因

 

      由于Java自启动服务占用了串口COM1,Python程序再次调用这个串口,出现“拒绝访问”错误。

 

3、解决办法

(1)将Java程序占用的串口暂停掉

(2)寻找另外一个串口COM3

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自www.cnblogs.com/odejsjhshw/p/10373180.html
0条评论
添加一条新回复