| Reference | Downloads | Github

PYO and basic import problem

Hi. I’m running my experiment on my laptop, Windows 7, 32.
I wrote whole experiment on one computer (also W7, 32) and it worked just fine.
but as soon as I run it on my laptop, it started to show this report, even for demos.
I tried my best to understand the problem, but I am exhausted now. I tried to manually setup PYO to get rid of sound problems, because the programm couldn’t detect it, but it still doesn’t see pyo.
maybe i’m just being dumb, because of being new to the whole python and psychopy thing.
please help to run it, it’s almost matter of my life (or at least the project with strict deadlines that I really want to be done)
and, also, please give me advices like you are telling it to the child (because as I said - have no experience and knowledge about the theme)

Here s report:


Hello Ann, not sure if this is the problem, but i wonder what would happen if you opened in a text editor (the file in the second blue line), and carefully put a ‘u’ in front of the string around line 75:

msg = u’%s audio lib was requested but not loaded: %s’

Hello, Daniel, and thanks for your help!

I did the thing, now report looks like that:

I installed PYO, but the programm still doesn’t see it, and I am puzzled why. Any suggestions?

How did you install pyo? One potential issue is that the standalone version of psychopy (which you are running) includes its own separate python, to guarantee it has everything it needs when installed.

If you want to install other python packages, and are using the standalone, you need to make sure you install them using Psychopy’s interpreter. So let us know how you installed pyo, and we can start to narrow down the issue.

But in short, if you are running things like this in the command prompt:


… or by simply typing ‘python’ (meaning python was added to your system’s path when you installed it):


… you’ve probably installed pyo in your system python, not in psychopy’s python. To do that you have to specify the path to psychopy’s python interpreter, which would be something like this (don’t quote me):

"C:\Program Files\PsychoPy2\python.exe"

You can try to type any of these three commands (which will bring you to the python prompt), and type

import pyo

My suspicion is that one or both of the first two will work, and the third will fail, which would mean you need to install pyo again using the third command to specify the right interpreter. Hopefully this is making sense or will make sense soon.

@jon , separately from the main issue here for Ann of pyo not being found/installed, it looks like the initial error that Ann reported here is a bug, since there was a unicode error when trying to log a warning message, and changing the string to a unicode object avoided that error. Am I right in my suspicions?

Ya know, sorry, should have thought of this earlier, but the latest version of Psychopy fixed a lot of bugs. Unless you have a good reason not to, I wonder if simply upgrading to the newest version of Psychopy will solve this problem.

I’m a bit lost with both errors! I think the first one is that when PsychoPy tries to report the error message it finds a unicode character and falls over; I can’t really imagine what that is but possibly it’s in the path/folder of the experiment(?)

For the question of why pyo isn’t loading I’m not sure.

Ann, could you go to the Shell (bottom of the Coder view) and type
import pyo
and tell us what it says in your preferences under the setting General>Audio Library>


Could be related to this issue then?

Hello, Jon and Daniel!

I tried to import pyo in shell/psychopy python and recieved this report:

If our suspicions are correct, it seems like pyo chokes when it needs any files in a folder containing non-ASCII characters (that is, any character that is accented or in a different script, and it looks like your system is using a Cyrillic locale).

This is of course no fault of yours, it’s a legacy of American programmers (and I’m American) not thinking about other countries when they wrote their programs.

So is pyo installed in a folder that has a non-ASCII character? Or is your script in such a folder? But it’s weird because it doesn’t look like it is.

@jon and @richard , should she try a different backend? Maybe ‘PyAudio’?

I doublechecked - there is no Cyrillic-named folders in path to Pyo or Psychopy. :frowning:

Definitely looks like aproblem with pyo on your machine and I don’t really have a clue why!
Could definitely try using one of the other audio backends by changing the preferences to have either ‘pysoundcard’ as the first option or ‘pygame’

I’m having trouble with pyo as well. Using standalone psychopy (1.84.2) on Windows 10. I installed pyo and chose C:\Program Files (x86)\PsychoPy2 as the installation directory. This created a few folders in PsychoPy2\Lib\site-packages\.

Here is the output from trying to import pyo from the PsychoPy shell:

>>> import pyo
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\", line 21, in <module>
    import pyolib.analysis as analysis
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyolib\", line 30, in <module>
    from _core import *
  File "C:\Program Files (x86)\PsychoPy2\lib\site-packages\pyolib\", line 32, in <module>
    from _pyo import *
ImportError: DLL load failed: The specified module could not be found.

There is a DLLs folder in the PsychoPy2 directory, but nothing related to pyo is in there, it is full of mostly .pyd files and some .dll files. I guess .pyd files are the same as dlls, right? There is a _pyo.pyd and also a _pyo64.pyd in Lib\site-packages\ . Maybe those are in the wrong place and not being found by python?

Note that pygame works fine for me, I just would like to use the Microphone class.