psychopy.org | Reference | Downloads | Github

core.openWindows() in 1.84.0 - AttributeError: 'module' object has no attribute 'openWindows'

Hello,

I recently upgraded to 1.84.0, though I had been using the beta versions for my experiment because I require microphone access and the newest versions were the only ones I could get to work. I have a few questions about how to make my experiment 1) work and 2) more less buggy.

First of all,
Out of the box, I tried to run my experiment and I received this:

pyo version 0.8.0 (uses single precision)
Traceback (most recent call last):
File "/Users/Dustin/Desktop/TRW_scan_comp/TRW_comp.py", line 69, in <module>
microphone.switchOn()
File "/Users/Dustin/.psychopy2/versions/psychopy/microphone.py", line 1023, in switchOn
sound.initPyo(rate=sampleRate) #will automatically use duplex=1 and stereo if poss
File "/Users/Dustin/.psychopy2/versions/psychopy/sound.py", line 642, in initPyo
core.wait(0.5)#wait for server to boot before starting te sound stream
File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/clock.py", line 219, in wait
for winWeakRef in core.openWindows:
AttributeError: 'module' object has no attribute 'openWindows'`

I also encountered this error using the previous beta release. As a quick and dirty fix I made these changes to clock.py by referencing previous versions:

    # removed lines 219-228
    #for winWeakRef in core.openWindows:
    #    win = winWeakRef()
    #    if (win.winType == "pyglet" and
    #            hasattr(win.winHandle, "dispatch_events")):
    #        win.winHandle.dispatch_events()  # pump events
    # added:
    try:
        wins = pyglet.window.get_platform().get_default_display().get_windows()
        for win in wins: win.dispatch_events()#pump events on pyglet windows
    except:
        pass #presumably not pyglet

I do not know the implications of this change, however, my experiment works for the most part.
This appears to happen when I turn the microphone on. I have adapted my code from the builder, but I haven’t changed much with regard to how the microphone and audio are handled (other than the filename of the saved wav file).
Any ideas why this is happening? I can’t recreate this in the previous stable release because i receive an immediate cannot find library pyo error.

Also, 2 other questions about the new version:

  1. In the release notes it says:

On Mac the 0.8.0 release of pyo audio lib, which is being packaged in this version of PsychoPy, is not closing properly with the ‘coreaudio’ backend so you might want to switch that to use ‘portaudio’ instead for now

So my question is how do I do this? I am using the coder view. Every time my experiment finishes, it doesn’t close properly. It saves all the necessary files but I still need to end the experiment manually.

  1. Every now and then I receive: Fatal Python error: (pygame parachute) Segmentation Fault

What does this mean?

I have attached my code, though it is very similar to the default code output by the builder. Thanks for your help!

Dustin

TRW_comp.py (33.9 KB)

To the first question I’m puzzled. I wonder whether you’ve got multiple versions of the psychopy library installed on your path. Could you go to the shell panel (bottom of the coder) and let us know the output of these print commands:

>>> from psychopy import core
>>> print core
>>> print dir(core)

Your hack to handle the error would potentially cause problems with detecting mouse/keyboard changes but little else (but I’d like to work out why the problem is occurring on your machine, since it isn’t on mine)

To the second part:

You can change the sound drivers in the preferences of the application. In the General tab there’s an option to set the “audio library” and the “audio driver”. Changing the order of the entries alters the order in which they get used in preference. You could try with adding 'pysoundcard' to the audio library before pyo to see if that gives you better performance. Or you could use pyo but tell it to use the 'portaudio' driver instead of the 'coreaudio' driver.

Thanks for the help!

Here is the output you requested:

from psychopy import core
print core
<module 'psychopy.core' from '/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/core.py'>
print dir(core)
['Clock', 'CountdownTimer', 'FINISHED', 'MonotonicClock', 'NOT_STARTED', 'STARTED', 'StaticPeriod', '__builtins__', '__doc__', '__file__', '__name__', '__package__', 'absolute_import', 'checkPygletDuringWait', 'getAbsTime', 'getTime', 'havePyglet', 'logging', 'monotonicClock', 'openWindows', 'print_function', 'pyglet', 'quit', 'runningThreads', 'rush', 'shellCall', 'shlex', 'subprocess', 'sys', 'threading', 'wait']

I am running this on the standalone 1.84.0 (PsychoPy2.app), however, I do have the previous beta installed as well: 1.84.0rc5 (PsychoPy_64bit.app). Since these are both standalone I assumed that they wouldn’t interact.

Ah! After some inspection, I think I found the issue. Awhile ago I played with the idea of installing psychopy on my own python distribution, thus I had a pesky ~/.psychopy directory that was messing with things. I removed this directory and it works much better.

However, I still have some issues with the experiment closing properly. I haven’t changed my code that I attached above, but I did change my audio settings to be:

audio library: [‘pysoundcard’,‘pyo’,‘pygame’]
audio driver: [‘portaudio’,‘coreaudio’]

After the end of the experiment, I still need to manually end. However, I have all of the output files I need.

Thanks again,

Dustin

OK, so we’ve solved the error with openWindows

To work out what’s happening with your audio settings could you run the auditory stimulus demo in the Coder and let us know what it says. It should report which audio libs it is using (might be that the others aren’t being found properly)

I ran soundStimuli.py:

##### Running: /Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/stimuli/soundStimuli.py #####
2016-08-22 07:55:15.690 python[20858:9894337] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/6c/tj4p58p128526xzy_hf23zkc0000gn/T/org.psychopy.PsychoPy2.savedState
pyo version 0.8.0 (uses single precision)
Using pyo(with None) for sounds
2016-08-22 07:55:16.969 python[20858:9894337] 07:55:16.969 WARNING:  140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.
1.9244 	WARNING 	pysoundcard audio lib was requested but not loaded: cannot load library /Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/site-packages.zip/_soundcard_data/portaudio.dylib: dlopen(/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/site-packages.zip/_soundcard_data/portaudio.dylib, 2): no suitable image found.  Did find:
/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/site-packages.zip/_soundcard_data/portaudio.dylib: stat() failed with errno=20
2.4724 	INFO 	sound is using audioLib: pyo
4.0050 	EXP 	Set  sound=C
4.0050 	DEBUG 	pyo sound server started
done
4.0071 	EXP 	Set  sound=A
4.0071 	EXP 	Sound  set volume 0.800
4.0073 	EXP 	Set  sound=800.0
4.0074 	EXP 	Set  sound=600.0
4.0077 	EXP 	Sound  started
4.8093 	EXP 	Sound  started
5.2098 	EXP 	Sound  started

I am using a Macbook Pro with OS X 10.11.6, if that helps.

Bump, any idea on closing the experiment properly?

Yes, it is the use of pyo to play sounds.

From the error message you’ve got there it’s clear that the request to use pysoundcard is not working because pysoundcard has failed to load. It isn’t managing to load the portaudio library from inside site-packages.zip. I guess I haven’t seen this crop up because I have that manually installed. So probably you could do one of these to get that sound library working:

  • install port audio yourself using home-brew
    or
  • extract the files from site-packages.zip (you could use the finder menu item “Go…” to find /Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/ and extract the zip file from there)

In the longer run I should be able to repackage this with the portaudio lib outside that zip file and it should work in future.

Hi Jon, thanks for the suggestions.

I unzipped site-packages.zip, but this still does not fix the problem.

Here is the output from soundStimuli.py

pyo version 0.8.0 (uses single precision)
Using pyo(with None) for sounds
2016-09-05 21:20:07.114 python[908:71334] 21:20:07.114 WARNING:  140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.
1.8470 	WARNING 	pysoundcard audio lib was requested but not loaded: cannot load library /Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/site-packages.zip/_soundfile_data/libsndfile.dylib: dlopen(/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/site-packages.zip/_soundfile_data/libsndfile.dylib, 2): no suitable image found.  Did find:
/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/site-packages.zip/_soundfile_data/libsndfile.dylib: stat() failed with errno=20
2.3801 	INFO 	sound is using audioLib: pyo
3.8863 	EXP 	Set  sound=C
3.8863 	DEBUG 	pyo sound server started
done
3.8894 	EXP 	Set  sound=A
3.8894 	EXP 	Sound  set volume 0.800
3.8897 	EXP 	Set  sound=800.0
3.8898 	EXP 	Set  sound=600.0
3.8901 	EXP 	Sound  started
4.6916 	EXP 	Sound  started
5.0924 	EXP 	Sound  started

There is no /site-packages/_soundfile_data directory, should there be?
I also tried to install port audio on my systems using brew in my terminal, but the problem persists.

OK, looks like the loading of pysoundcard wasn’t finding one of the libs. That should be fixed in new version just released:

Thank you, Jon! This fixed the library problem. However, this line of investigation brought me to another, tangential problem. I am marking this issue as solved, but I want to create a new thread with a more informative title with respect to the new problem.