# Help Installing Tobii into Psychopy Builder

**URL:** <https://discourse.psychopy.org/t/help-installing-tobii-into-psychopy-builder/38991>\
**Category:** Coding\
**Tags:** eyetracking, code\
**Created:** [March 6, 2024, 12:22am UTC](https://discourse.psychopy.org/t/help-installing-tobii-into-psychopy-builder/38991 "2024-03-06T00:22:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![synaptech](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/synaptech/32/39026_2.png) [@synaptech](https://discourse.psychopy.org/u/synaptech)\
**Post date:** [March 6, 2024, 12:22am UTC](https://discourse.psychopy.org/t/help-installing-tobii-into-psychopy-builder/38991/1 "2024-03-06T00:22:59Z")

</div>

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()

---

<div class="post-metadata">

**Author:** ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)\
**Post date:** [March 11, 2024, 2:02pm UTC](https://discourse.psychopy.org/t/help-installing-tobii-into-psychopy-builder/38991/2 "2024-03-11T14:02:44Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![synaptech](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/synaptech/32/39026_2.png) [@synaptech](https://discourse.psychopy.org/u/synaptech)\
**Post date:** [March 11, 2024, 2:14pm UTC](https://discourse.psychopy.org/t/help-installing-tobii-into-psychopy-builder/38991/3 "2024-03-11T14:14:51Z")

</div>

Hi,

How would you suggest importing iohub?

---

<div class="post-metadata">

**Author:** ![jonathan.kominsky](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jonathan.kominsky](https://discourse.psychopy.org/u/jonathan.kominsky)\
**Post date:** [March 11, 2024, 2:23pm UTC](https://discourse.psychopy.org/t/help-installing-tobii-into-psychopy-builder/38991/4 "2024-03-11T14:23:15Z")

</div>

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:

```auto
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.
