Psychopy for Eyelink Audio Errors

Hello,

I have been trying to find the best Python-based coding method to run an experiment requiring audio and visual syncing. My hope was to use psychopy from the display pc (laptop) to display visuals, drive audio output and recording, and communicate with an Eyelink eye tracker device and its host computer.

Getting a python version on an Apple M4 to do this has been pretty difficult. I hit two errors.

I used Python 3.10 because it says it seemed to have the best Mac (running Tahoe, also tried Sequoia) compatibility with Eyelink 1000 Plus (also tried 3.11, 3.12).

  1. I tried installing everything with Psychtoolbox after downloading the Eyelink developer, using the arm Mac pylink download then downloading Psychtoolbox as part of a virtual environment. I got in a loop where I was asked to repeatedly use brew install for libusb and to link it and to point to the path, but it did not work. The code error said that PsychHID compiled and could not find the libusb_bulk_transfer.

  2. I did the install again in 3.10 in a new environment, and I was trying to use psychopy without Psychtoolbox. The visual task ran, and I tried to point psychopy.prefs to other audio libraries like pygame, or sounddevices. I used prefs.general and prefs.hardware, and nothing worked. I saw that after a psychtoolbox install and uninstall there was another error: File
    "/opt/miniconda3/envs/eyelink_env/lib/python3.10/site-packages/psychopy/hardware/speaker.py", line 14, in <module>
    import psychtoolbox.audio as ptb[/color][/font][/size]
    ModuleNotFoundError: No module named 'psychtoolbox'

I am open to editing something like in 2 but it seems like core code for psychopy.

Again the goal is to drive audio and visual and be able to talk to the Eyelink while keeping time syncing. Any recommendations or solutions would be so appreciated.

I recommend using the PsychoPy app and the eyelink plugin for this: Communicating with an Eyetracker — PsychoPy v2025.2.3

The app comes with its own python environment and you don’t need to do a separate PTB install, you just need the plugin and the eyelink devtools.

1 Like

Thanks for your reply!

I ended up wanting to code the task in python file triggering other functions, especially audio from other devices. So, for now I created a c code that points to the files in my condo environment which fixed the first error. Then I had one more issue with a debug function “PaUtil_SetDebugPrintFunction()” being missing. I set it as an empty function that just prints that it was called, and so far the visual is working.

The audio is still something I’m working on. Currently, trying to figure out how to put audio on individual channels of an audio interface via sound.Sound and record different channels through Microphone. So far, the channel routing doesn’t seem possible so I’m considering going through thesounddevice package directly.

As I recall it’s very difficult to get the sound.Sound object to control individual channels. I think if you try to control multiple separate channels it just crashes, or at least it did last time I tried messing with it. You may indeed have an easier time using the sounddevice package directly.

Also, when I say the app makes its own python environment, any Python script you run from the app’s coder interface uses that environment, including any plugins etc. If you need to interface with it through C, then you probably need a separate environment, but if you can do it all in Python, you may have an easier time using the PsychoPy app as an IDE and running from its environment.