psychopy.org | Reference | Downloads | Github

"serial" only works in the Shell

Hello,

I’m using PsychoPy 2020.2.8 on Windows 10.

I’m trying to use a Cedrus button box (Model RB-620) which is connected to the computer using a serial port. Using the Cedrus response component in the builder didn’t work, because it can’t find/access pyserial, so I decided to code the experiment.

I am testing this basic code which I found on the pySerial website at the moment:

import serial
ser= serial.Serial("COM1")
print(ser.name)
ser.write(b'hello')
ser.close()

This works perfectly in the shell, but when I try to run the code from the editor, I get the following error message:

Does anyone have any idea how I can get the serial commands working from a script in the editor?

Thank you!