Failed import of psychtoolbox results in nonfunctional keyboard

Hi all, hoping that someone might have some ideas or pointers about this issue I’m running into.

I was following along with this introductory tutorial, and found myself unable to use keystrokes to close out of the window.

However, if I replace kb.getKeys() with event.getKeys, then the program recognizes keystrokes as expected.

After tinkering about a bit, it seems like the root issue has something to do with a failure to import psychtoolbox. Below is a representative error message.

import psychtoolbox
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jaeyoungson/opt/anaconda3/envs/psychopy/lib/python3.10/site-packages/psychtoolbox/__init__.py", line 28, in <module>
    from .PsychHID import PsychHID
ImportError: dlopen(/Users/jaeyoungson/opt/anaconda3/envs/psychopy/lib/python3.10/site-packages/psychtoolbox/PsychHID.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_libusb_bulk_transfer'

Sure enough, if I call psychopy.hardware.keyboard.getKeyboards(), it returns an empty list.

If it’s at all possible, I’d prefer to use the functionality of psychopy.hardware.keyboard over the keyboard functions in psychopy.event, so any tips would be greatly appreciated!

What have I tried so far?

  • Verifying that this problem isn’t caused by use of an external monitor + keyboard (by disconnecting all peripherals).
  • Deleting my conda environment and then reinstalling psychopy + all dependencies (all installation seemed to go smoothly w/ python=3.10).
  • Attempting to install psychopy using other versions of Python (ran into various hiccups trying to pip install dependencies w/ python=3.8 and 3.9, but was able to at least install psychopy and psychtoolbox), verified that I get the exact same error.
  • Searching through GitHub issues, Discord threads, and API documentation for relevant info. Always possible, of course, that I’ve missed something obvious!

What’s my setup?

  • Running on 2021 MBP w/ M1 Pro CPU, macOS Sonoma 14.6.1
  • Creating virtual environments w/ conda, then pip installing psychopy
  • Currently using psychopy version 2024.2.1 while waiting for the latest version to be installable via pip

I’m not sure about the error with psychtoolbox importing, but you should be able to set the keyboard backend to be ioHub via Experiment Settings :experiment_settings: - under the Input tab.