psychopy.org | Reference | Downloads | Github

Coding via Spyder - AttributeError: No audio API found. Try installing pyo 0.6.8+, or pygame 1.8+

I know this may not be the best of place to ask for help in regards the title mentioned error, but I believe some of you here should have experience running psychopy via spyder. I’m currently using Python 2.7 on Windows 8.

The sound module could be loaded without problems on my standalone psychopy (1.83.04) but running the simple ‘from psychopy import *’ on spyder (I have pythonpathed spyder to psychopy and all non-audio modules were imported successfully and can be used) resulted in the AttributeError message.

On a seperate note, Pyglet, on some of my students’ laptops, couldn’t be loaded up as well even after Pyglet was seperately installed.

Does anyone have any suggestion as to how to go about fixing these?

This isn’t really an answer to your question (because I don’t know why pyo would be a problem like this) but be aware also that Spyder is not designed to run your code fast. It has additional hooks to allow debugging etc that may slow down your scripts a little. It’s great for editing but not ideal for running your experiment (for which simple is actually better) just so you’re aware

1 Like

What Python distribution are you using, and how did you install PsychoPy, pyo and Pyglet there?

As a stylistic suggestion, you should really avoid from foo import *-like imports, as they clutter the namespace and obfuscate the origin of the imported objects.

I installed 2.7 via the Anaconda package. Psychopy was installed using the standalone version and prior to this issue, I have two earlier error prompts that said Pyglet and wxpython could not be found and I had to install Pyglet and wxpython manually. I tried installing pyo manually as well but Spyder could not detect it.

On Psychopy however, all modules could be loaded fine. I’m guessing this has something to do with a faulty path?

Thanks for the advice. I actually just used “from psychoy import *” just to check if all modules could be imported successfully in this debugging instance.

I regularly do install a “psychopy stack” on Anaconda, and I cannot really reproduce your problems. To get PsychoPy up and running (without audio and ioHub support), the following commands should be executed from the Anaconda prompt:

conda install wxpython
pip install pyglet psychopy

To get audio support from Pyo, you indeed have to install it manually from a setup file:
http://ajaxsoundstudio.com/downloads/pyo_0.8.0_py2.7_setup.exe

Select the Anaconda base directory as installation target.

This should definitely work, I recently followed this procedure during a workshop and we got PsychoPy to run on 10 computers running all kinds of different Windows versions (7 to 10).

Good luck!

Edit
If you don’t need Pyo, you may also use PyGame for audio playback. Simply do a pip install pygame, and skip the Pyo installation step.

2 Likes