[Python] SerialException: could not open port (Access is denied)

Discussão em 'Python' iniciado por Stack, Janeiro 31, 2025.

  1. Stack

    Stack Membro Participativo

    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!

    =)

    Continue reading...

Compartilhe esta Página