| Reference | Downloads | Github

Use of Tobii Pro SDK

Hello everyone,

I am currently trying to design an experiment with EEG and Eyetracker (Tobii) for infants.

I am pretty sure the solution is not that complicated but I couldn’t make it work…
For now, I don’t have any problems to import the tobiiresearch library but I am not able to use the functions related to this packages. I assume I didn’t install it correctly maybe.

Here is my configuration :

What I did for now is download the tobii SDK folder, extract the one named “tobiiresearch” and move it to
I also tried to place it directly into the lib folder

When I run the command into the Psychopy Shell :

import tobiiresearch as tr
import time

found_eyetrackers = tr.find_all_eyetrackers()

I get the error :

found_eyetrackers = tr.find_all_eyetrackers()
AttributeError: ‘module’ object has no attribute ‘find_all_eyetrackers’

It seems that the import command do not cause any error but using the function does…

Is anyone thinking of something that might help me?

the module is called tobii_research. To import it, it should be import tobii_research as tr.
Just a side note, I wrote a simple package to work with Tobii eyetracker and PsychoPy, maybe you will find it helpful. The package is based on Python 3 so be cautious about it.

Good luck!

Hi !

Thanks for your reply but it didn’t help my case.
The recent folder downloaded from the official website tobii pro SDK is name tobiiresearch and not tobii_research. The different files inside this folder refers also to this new name as well.

My problem is not the import since I didn’t show me any error i think …

Yeah thanks I already saw your module I already plan to take a look :wink: although I will do it on my own because I want to keep python 2.7 for some reason of compatibility with egi.

Sorry for the misunderstanding!
Is it possible that Python did not import tobiiresearch correctly?
If you put tobiiresearch in the same folder of your experiment to use it, does it work?

Firstly, you said that you use the python libraries that come with Mac (which are usually not very complete), but later on you say that you copy the files into the PsychoPy folder. Copy-pasting folders is not something I recommend. However, PsychoPy does come with pip. You might need to upgrade pip but I’d strongly recommend using that for installing modules.

Secondly, have you checked whether the folders you copied are in your sys.path ?

Finally, I suspect that find_all_eyetrackers() is not a module but a submodule, and these are not automatically imported. Actually, whilst I was typing this, I had a look at the folder structure of the download. try:
from tobiiresearch.implementation import * as tr ?

As a sidenote, is there any reason you import time? PsychoPy’s core module has a lot of good timing options in my opinion.

Hello, thanks for you reply and suggestions!

What I meant when I said that I use the python libraries that come with Mac is that I didn’t install python on this machine (using PyPi or whatever), I’ve just install Psychopy assuming python already exist on my Mac.

  1. Pip

I wanted to use pip to install the package properly but I never manage to succeed.
I try typing the following command in the psychopy shell (either tobii_research or tobiiresearch): pip install tobii_research
get the error :

pip install tobii_research
  File "<input>", line 1
    pip(install tobii_research)
SyntaxError: invalid syntax

When I try directly in the terminal I get the error : /usr/bin/python: No module named pip, or if I try directly in the terminal : -bash: pip: command not found, or by running python first in the terminal I get the exact same error as in the Psychopy shell …

  1. pth

Secondly, yes I created a file tobii.pth containing : /Applications/, by following the procedure presented here :

  1. import

I tried the command you suggested : from tobiiresearch.implementation import * as tr

from tobiiresearch.implementation import * as tr
  File "<input>", line 1
    from tobiiresearch.implementation import * as tr
SyntaxError: invalid syntax

I noticed that after typing import tobiiresearch as tr when I type tr. I get few options that I join as a screen capture.50

Sorry for all those details, but I am pretty new using Psychopy and Python I am just trying to make it easier to you understanding what I suppose to be a dumb mistake of my…

Concerning the side note about import time, I just wanted to follow the tobii pro SDK procedure and also show that import command with other package did not cause any problem.

No that’s not a problem at all! I am pretty sure there is a problem of installation/import too.
Sorry it did not work, it’s always the same errors…

It’s really weird you get the error… I cannot reproduce the error on my machine :frowning:

The pip-related problem:

  • Install pip: download and run it with python
    python to see if that solves the problem.

I didn’t have much experience with PsychoPy standalone and its shell, as a result I suggest an alternative solution:

Use a virtual environment

  1. Create a virtual environment and manually install PsychoPy.
  2. Install tobii_research via pip
  3. Test a simple script using python (venv)$ python (or just type in the python interpreter)
import psychopy
import tobii_research as tr
found_eyetrackers = tr.find_all_eyetrackers()
for tracker in found_eyetrackers:
    print tracker

Sorry not being helpful, hope your problem get fixed soon!

  1. to install via the terminal, first navigate to the PSYCHOPY subfolder that contains Python (let’s ignore your pre-installed Mac version from now on).

python -m pip install --upgrade pip

pip install tobii_research

However, it is possible to install it from within your shell:

import pip
pip.main(['install', tobii_research])
  1. That’s my mistake. Perhaps simply try:
    import tobiiresearch.implementation as tr

But I’d stick to method one first :slight_smile:

  1. pip

I did it through the shell of Psychopy to be sure that I am at the right place. There is definitely an error with the pip:

import pip
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "pip/__init__.pyc", line 43, in <module>
  File "pip/utils/__init__.pyc", line 23, in <module>
  File "pip/locations.pyc", line 10, in <module>
  File "distutils/command/install.pyc", line 21, in <module>
ImportError: cannot import name USER_BASE

The command you suggest pass without any error and tr. suggest other proposition. However, I get the same error as before when using the find_all_eyetrackers() function…

I am trying the suggestion of @yh-luo for the moment

Thanks @Cesco and @yh-luo !!

It is currently working :slight_smile:
To resume : It seems that pip is not (or not correctly) installed with my current version of Standalone Psychopy.

I used those command in the terminal :

sudo easy_install pip
pip install --user tobii_research

everything was installed perfectly I just add the path of that module to Psychopy in the settings : [u'/Users/marie/Library/Python/2.7/lib/python/site-packages', ]

I assume that it wasn’t installed correctly from the begging don’t really know why. Thank you again for your help. :slight_smile:

Happy you made it work!

In fact I replicated the USER_BASE error when I tried the shell myself; potentially hinting at corrupt scripts in the OSX distribution. Either way, I find that using the terminal usually works best. As you found out :wink:

1 Like