| Reference | Downloads | Github

NameError: name 'io' is not defined

Hello everyone, there was a problem with connecting the library to the experiment code, I would be very grateful for any help?
**OS: Win10
**PsychoPy version: 2020.2.4
**Standard Standalone?:y
What are you trying to achieve?:
I want to connect oi for further use of iohub library functions

What did you try to make it work?:
I add this code(it is executed before the experiment) -> “io = launchHubServer(**iohub_config)” in one of my routine to connect the library. In the console I get this error “NameError: name ‘io’ is not defined”

What specifically went wrong when you tried that?:
I got error “NameError: name ‘io’ is not defined”

Include pasted full error message if possible. “That didn’t work” is not enough information.

Could you please post the full code you are using to start iohub in your experiment? It sounds like your script is trying to access the io object before it has been created. The iohub initialization code should include something like:

from psychopy.iohub import launchHubServer

# Start iohub
io = launchHubServer()
# Get the default keyboard device created.
keyboard = io.devices.keyboard

### Insert experiment code here
# ...

# Quit iohub server