Serial PermissionError(13, 'Access is denied.', None, 5) in EEG experiment (biosemi)

Win10 (e.g. Win10):
PsychoPy 2023.2.3 (e.g. 1.84.x):
Standard Standalone
I’m trying to set up an EEG experiment. For this to work properly, PsychoPy is supposed to send the triggers when a specific key is pressed by the participant. As such, to make sure this works, we are running a very short algorithm in our lab to test the triggers, but this doesn’t seem to be working.

**What did you try to make it work?:
I am aware of three other posts made here with regards to the issue and have tried all the solutions offered in the posts. These include:

  • Trying out different versions of PsychoPy to make sure it isn’t just a bug from the version I’m using, as seen here. This made no difference to the issue, so I’m assuming it doesn’t have anything to do with the version I’m using.

  • Made sure nothing else is using the Port - Matlab was able to access it without any issues, right after PsychoPy tells me it doesn’t have access to the port.

  • Reassigned the port to a much larger number, as suggested in post number 34216 (would include link here but it isn’t working), and also used the code suggested here to “clear” the port (this is the method I normally use in Matlab to do it). This simply resulted in no changes to the issue. The code I use in Matlab to clear it is:


I’m not sure if there is a Python-equivalent to this that I can include in the beginning of my experiment. I’ve tried to do it myself but to no avail, the program just ignores the code I’ve written (I assume since it makes no difference to the output or this issue).

  • Uninstalled and re-installed the usb, removed it and plugged it back and made sure its settings were correct (biosemi equipment has specific baud rate requirements) in device manager.


**What specifically went wrong when you tried that? **
Full error message:

raise SerialException("could not open port {!r}: {!r}".format(self.portstr, ctypes.WinError()))
serial.serialutil.SerialException: could not open port 'COM4': PermissionError(13, 'Access is denied.', None, 5)
################ Experiment ended with exit code 1 [pid:10544] #################

Maybe this could be solved with some coding, as this is how I normally solve this issue in Matlab, but unfortunately I’m not proficient in PsychoPy (or the Serial module) enough to know how to do so, any suggestions? Happy to give more detail if needed!

Do any of these links help?

Unfortunately not, these are the posts I mentioned having consulted and tried already :confused:
None of the suggestion/guidance originating from those 3 posts managed to solve my issue.

Thank you for the suggestion though!