Help Installing Tobii into Psychopy Builder

Hi,

Im having trouble connecting Tobii to psychopy. I keep getting error messages that it cannot import name ‘launchHubServer’ from ‘psychopy.iohub’ despite redownloading python 3 and reinstalling pip and iohub via the cmd on my windows desktop. PI currently have the following code in my psychopy builder:

from psychopy.iohub import launchHubserver
from psychopy.core import getTime, wait

iohub_config = {‘eyetracker.hw.tobii.EyeTracker’:
{‘name’: ‘tracker’, ‘runtime_settings’: {‘sampling_rate’: 120}}}
io = launchHubServer(**iohub_config)

#get the eye tracker device
tracker = io.devices.tracker

run eyetracker calibration

r = tracker.runSetYpProcedure()

tracker.setRecordingState(True)

stime = getTime()
while getTime()-stime < 2.0:
for e in tracker.getEvents():
print(e)
stime = getTime()
while getTime()-stime < 5.0:
print(tracker.getPosition())
wait(0.1)
tracker.setRecordingState(False)

io.quit()

from psychopy.iohub.client import launchHubServer

launchHubServer is part of the “client” sub-library, which is why importing it directly from iohub doesn’t work.

Hi,

How would you suggest importing iohub?

If you are using an up-to-date version of the PsychoPy standalone app in coder view or with a code component (use the “before experiment” tab), you should be able to just put this at the start of your code:

from psychopy.iohub.client import launchHubServer

and everything else as in your example code. Note that this is different from the code you shared, because it’s importing from psychopy.iohub .client instead of just psychopy.iohub. You shouldn’t need anything else to use the eye-tracker once you call launchHubServer.

If you aren’t using the standalone app I’m not sure. The iohub library should be included with any installation of the psychopy library, so it should work the same way, but at worst you could try using the standalone app.