PySerial [Error 5] Access is Denied

泪湿孤枕 提交于 2019-11-30 23:27:36

UPDATE: This is apparently no longer possible in PySerial 3.0.

Under Windows, I've always used the port=<int> approach with success.

I.e. change your code to:

c = serial.Serial(3, 9600)

For me the solution didn't work but what worked was closing all the applications that were interacting with the given com port.

For Python 2.6 use the zero-based COM port index. For Python 2.7.x you can use the full name "COM4". From my experience it's better to use the 2.7 version. Install Python 2.7.x and Setup Tools (aka Easy Install). Once you've got this, install pyserial module by typing easy_install -U pyserial (see pyserial installation doc).

Remember to add python path to PATH environmental variable.

Please, take care with the python versions.

From the pyserial manual about: class serial.Serial https://pyserial.readthedocs.io/en/latest/pyserial_api.html#classes

...........

The port is immediately opened on object creation, when a port is given. It is not opened when port is None and a successive call to open() is required.

port is a device name: depending on operating system. e.g. /dev/ttyUSB0 on GNU/Linux or COM3 on Windows.

............

Changed in version 3.0: numbers as port argument are no longer supported

that works with PORT COM N-1 in python (N is your number of COM)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!