I am writing Python v2.x in Windows7 OS. When I run my code, the following error happens frequently.
serial.serialutil.SerialException: could not open port 'COM4': WindowsError(5, 'Access is denied.')
Here are what I did:
1) I check device manager, COM 4
can be seen, but cannot open
2) In my code, I do close COM
port after using it
3) Here is COM
config in my code: ser = serial.Serial( "COM4", 9600, timeout=0.05)
4) I reboot computer, the problem is gone, but it happens again after a while
5) I wonder it is a problem related to my Python code or Windows system?
So considering above fact, could anyone help me out? Thanks and Happy New Year!
=)
I had Ultimaker Cura Slicer (for my 3D printer) open, and that was holding control of the COM3 port for some reason. Once I killed that app, then it (VSCode) worked fine for uploading code to my ESP-8266
You port COM4 may be open in the arduino IDE serial monitor.
close the serial monitor in the arduino IDE.
This may solve your issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With