I am running PsychoPy 2023.2.0 as standalone on a Mac M1 (macOS Ventura 13.5). I want to use the module pyo in a project to send sounds to 1,2 or 3 out of 4 output channels. I am starting with the following code in the coder:
import pyo as pyoSound
pyoServer = pyoSound.Server()
import pyo as pyoSound runs without problems, suggesting that the module is installed. However, subsequently creating the sound server with
pyoServer = pyoSound.Server() fails, returning the error message
AttributeError: module 'pyo' has no attribute 'Server'.
Running the very same lines in e.g. PyCharm with Python 3.8.18 in a pyenv with pyo installed via pip executes fine, showing pyoServer as (
<pyo.lib.server.Server object at 0x100a5b4c0>).
in the PsychoPy console returns
<module 'pyo' from '/Applications/PsychoPy.app/Contents/Resources/lib/python38.zip/pyo/__init__.pyc'>
I remember having problems with importing pyo in previous versions of PsychoPy (something like 1.8.x, IIRC). Can someone point me into a direction here or has successfully used pyo in a recent project (but not as sound backend)? Any pointers are very much appreciated!
In 2023.1.0 we moved the pyo backend to a plugin, do you have
psychopy-pyo installed? You can manage plugins from Builder via “Tools → Plugins/Packages manager…” in the menu bar. With that plugin you should just be able to use Sound components/stims and just set the backend, without worrying about directly interacting with pyo.
It could also be to do with the version of pyo installed, I’m not overly familiar with the module but could it be that Server has been moved/renamed between the version in your standalone install and the version in your venv install?
Hi and sorry for the late response. I just managed to post the question before my vacation.
Thanks for the information about the new way the backends are implemented in the current version of PsychoPy. Also pointing me towards the “Plugins/Packages manager” was great! Did not know about that. That is a great addition! That helped me with other things, but did to solve my current problem.
To provide some more background first: I do not want to use pyo as a backend for the sound class, but instead play sound via its functions directly. A basic code snippet would look like this:
pyoServer = pyo.Server(nchnls=2)
snd1 = pyo.SfPlayer(path="/sounds/440_Hz_500_ms.wav)
The pyo module is not listed in the “Packages” tab in the "Plugins/Packages manager, but could also not be installed via pip or file from there. The former stopped with an error:
In file included from src/engine/ad_portaudio.c:21:
include/ad_portaudio.h:24:10: fatal error: 'Python.h' file not found
1 error generated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]
Trying to install pyo using any of the macOS files (downloaded from pyo · PyPI) yielded the error:
ERROR: pyo-1.0.5-cp39-cp39-macosx_13_0_arm64.whl is not a supported wheel on this platform.
Out of curiosity, I tested the code snipped on our lab computers running the standalone on Windows 11 and it worked. Unfortunately, that seems to be a macOS problem. Still, I hope there will be a solution for that. I will continue testing and try to install the package directly and access the functions from within PsychoPy. I will post (hopefully) positive results :-). If there are any other ideas and/or solutions, please let me know.