"Permission Denied" usb serial port error

PsychoPy version 2023.1.1

What are you trying to do
Send triggers to a USB Device via COM4

  • My experiment works perfectly when it’s connected to a Mac running Psychopy 2022.2.5 and the triggers work
  • When i try to open and run the same experiment on the computer at our MRI machine, I run into this error:
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)

What did you try to make it work?:
Fixes here and here

  • Checked that COM4 is not in use by anything else (when I unplug and replug the USB, COM4 reappears and disappears)
  • Checked that the usb device can receive triggers using CoolTerm - it definitely connects via COM4 and I was able to send and receive triggers
  • Updated from 2022.2.5 to 2023.1.1 on the MRI computer
  • Added Pyserial code in Begin Experiment to create the port object that way

What specifically went wrong when you tried that?:
I still get the error :frowning:

Hi! I managed to get things to work and am posting here in case it helps anyone else

I tried a few things but I think the main issue was that I had 2 psychopy experiments (both with serial port components) open at the same time. Even though I wasn’t running the second (it was open to cross reference code), it may have still been accessing the port.

Other things to try:

  • I reassigned the port to a much higher port number
  • Uninstalled and reinstalled USB drivers
  • Re-started the computer