Future of Psychtoolbox + PsychoPy

Hi all! Recently, I’ve gone down a rabbit hole trying to get PsychoPy to work on an M4 Mac when installed via pip (i.e. not the Standalone install). Took some time and playing around, but we ultimately got it worked out.

That said, through this process, I noticed that pip installs version 3.0.19 of Psychtoolbox, and the current version of Psychtoolbox (as of January 2025) is 3.0.20 (which natively works for Apple Silicon chips). As per PTB’s announcement, they’re moving towards requiring a paid license key for Windows and MacOS (if I’m reading their announcement correctly).

Given this announcement, are there any plans in the works for handling this with PsychoPy? In trying to debug our issue, I’ve noticed that many of the solutions from the forum on issues with keyboard input just suggest ensuring the PsychoPy backend is PTB. We’re also thinking about the longevity of our code - if PsychoPy will no longer be able to use PTB after the current version, it would make more sense for us to make sure things work with another backend rather than just letting it choose PTB.

Thanks in advance!

Hi @crewalsh thanks for the info.

Is there any info to share about getting things running on native ARM? I haven’t looked at this for a while but if it’s now fully possible then I’ll try and dig in to it and make some builds of our own on native

Regarding PTB, I’ve emailed Mario repeatedly asking for a chat about a) how we can fund him and b) how the licensing will work for psychopy users. He hasn’t provided any info on either aspect. So, while he constantly complains that people don’t pay him enough, he makes it surprisingly hard for us to pay him! But maybe he’s just crazy-busy setting up the business model (e.g. license and online store) and he’ll reply once that’s all in place. It looks like PTB licenses will cost €50 per year, but I don’t know if that applies to the PTB python lib

1 Like

Hi Jon,

That’s good info! Yeah, that’s pretty much what I could intuit from reading the PTB updates/forum posts about setting up the business model process and costs, but wasn’t sure if you had any behind-the-scenes additional information. It seems like he mostly focuses on making PTB work well for MATLAB so there wasn’t much info about running it on MacOS or the Python package.

Yes and no re: native ARM. ;tldr, we don’t have a setup that works natively with Silicon chips, but we have managed to get something working on our M4 laptops.

For posterity (and since I couldn’t find many recent posts on the forum about this): We first just tried to pip install psychopy in a clean conda environment, but were getting all sorts of issues. Then, we tried to follow these instructions, but we ran into the first known issue they list (an import issue with PTB):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/_____/psychopy-on-M1/venv/lib/python3.10/site-packages/psychtoolbox/__init__.py", line 26, in <module>
    from .WaitSecs import WaitSecs
ImportError: dlopen(/Users/____/psychopy-on-M1/venv/lib/python3.10/site-packages/psychtoolbox/WaitSecs.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_ActivateLicense'

When I first was working on this, I assumed that it was an issue with ARM (since we were getting errors that looked a lot like that previously), but now looking at it, I’m not actually not sure if this is the fact that we don’t have a license. Regardless, it wasn’t working, so we pivoted.

Ultimately, what we ended up doing was creating an Intel environment via conda:
CONDA_SUBDIR=osx-arm64 conda create -n psychopy_env_x86 -c conda-forge
and then pip installed psychopy with the dependencies (python version 3.10.16) - this got us psychopy==2024.2.5 and psychtoolbox==3.0.19.14. Notably, this version is NOT the version of PTB that runs natively on ARM, and from the PTB side, it does seem like they recommend going up to 3.0.20 for this reason (timing, etc). We haven’t tested this at all so I don’t know how bad the timing issues are (/ if they’re an issue at all).

That allowed us to successfully import the packages, but we still were coming across issues with PTB having access to the keyboard - PTB had some instructions to change security settings (allow Terminal access to Input Monitoring in Security & Privacy) but after doing that, we still got the following error:

PTB-WARNING: During PsychHID invocation: Some other running application is preventing me from accessing the keyboard/keypad/mouse/...!
PTB-WARNING: This is likely a security measure, e.g., to protect some active password entry field.
PTB-WARNING: Please identify and quit the offending application. E.g., some versions of Firefox are known to cause such problems...

What fixed this was also giving Terminal access to Privacy & Security → Accessibility in addition to Input Monitoring.

After doing all these steps, we were successfully able to run the keyNameFinder.py Coder demo with both the iohub and ptb backend (although it didn’t seem to work with the event backend). We also had some weirdness with using the psychopy iohub module but we figured out that it worked well with the psychopy.hardware.keyboard.Keyboard() object so we didn’t dive too deeply into this.

Catherine

OK, thanks for that info. So the message symbol not found in flat namespace '_ActivateLicense' surely relates to the new requirement to have a license from PTB to use the lib, whether you’re using the matlab one or the python version (which is only keyboard and sound functions). According to https://www.psychtoolbox.net/ the license will cost £50 per user per year but there isn’t yet a means to buy a license

So, for now I think you need to stick to 3.0.19 which doesn’t have those license issues but also certainly doesn’t support native ARM chips.

So that leaves the issues you were having which I think have been covered elsewhere too:

  • you do need to allow Accessibilty and also Input Monitoring to use iohub or PTB backends, and if you run scripts from the Terminal then this is what eneds that permission
  • if you have an ARM-based Mac (M1/2/3/4… chips) then you need to make sure that you use Intel-based Python which should automatically be translated by Rosetta