Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SerialException: could not open port (Access is denied)

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!

=)

like image 210
Amber.G Avatar asked Dec 31 '15 18:12

Amber.G


2 Answers

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

like image 195
NumericOverflow Avatar answered Oct 06 '22 00:10

NumericOverflow


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.

like image 22
ANIL KUMAR S Avatar answered Oct 06 '22 01:10

ANIL KUMAR S