RuntimeError: Wrong version of PyObjC C API

Hi everyone,

I’m reposting this from the Builder forum as it seems to be more of a coding/environment issue and hasn’t received a response. I tried to delete the original to prevent duplicating the topic but couldn’t find a way. For full context, the original post is here: RuntimeError: Wrong version of PyObjC C API with added Python package (godirect) and Builder components

The Problem

I am encountering a dependency conflict on macOS when using the godirect package (for a Vernier dynamometer) in an experiment that also uses standard PsychoPy GUI components (e.g., a Button component). My custom code to initialize and use the godirect library works perfectly on its own, but the experiment fails as soon as a GUI component is added to any routine in the project.

System Details

  • PsychoPy Version: 2024.2.4
  • Operating System: macOS Sequoia 15.4.1 (but the experiment must ultimately run on Windows as well)
  • External Package: godirect, installed via pip from the PsychoPy Runner.

The Error

When a GUI component is present in the experiment, I receive the following error, which points to a conflict with the PyObjC library used by PsychoPy and a dependency of godirect:

RuntimeError: Wrong version of PyObjC C API (got 25, expected 21)

What I Have Tried

  • Reordering Routines: The error occurs regardless of the order of the routines.
  • Package Versions: I’ve tried the latest godirect version and older ones with no success. Our lab (ideally) needs to stick with PsychoPy 2024.2.4.
  • Builder vs. Coder: I strongly prefer to solve this within a code block in the Builder. However, I am willing to move to a pure Coder/conda environment solution if that is the only robust path forward.

The experiment is running on a shared lab laptop, so creating a self-contained conda environment is a feasible solution if necessary. I would be super grateful for any tips to solve this issue so I can use the Vernier device within the PsychoPy experiment I already have.

Thank you in advance for any guidance you can provide!

Hello @MariaAL

I don’t know much about Python, but this doesn’t look like a PsychoPy error. It looks more like a conflict between the expected and installed Python libraries. In this case, it’s PyObjc. The installed version is newer than the expected one.

Does the error occur when you run an experiment without the GoDirect Hand Dynamometer? If not, I would ask the GoDirect Hand Dynamometer team if they could update their library to PyObjC or advise on how to solve this conflict. Alternatively, you could downgrade your PyObjC library using pip. However, I do not know what side effects this would have on PsychoPy.

Best wishes Jens