‘NoneType’ object has no attribute ‘filename’ when running any Coder function


I am new to PsychoPy and am trying to do the tutorial here: Tutorial 1: Generating your first stimulus — PsychoPy v2022.2.4

Whenever I try to do save or run a script, I receive the following error:

Traceback (most recent call last):
  File “/Applications/PsychoPy.app/Contents/Resources/lib/python3.8/psychopy/app/coder/coder.py”, line 2623, in runFile
AttributeError: ‘NoneType’ object has no attribute ‘filename’

When I run the simple stimulus code in the tutorial (below), the window with the circle and fixation block appear as expected, but the window immediately freezes, and I need to force exit the window. I am not sure if this error is related to the other error described above.

from psychopy import visual, core  # import some libraries from PsychoPy

#create a window
mywin = visual.Window([800,600], monitor="testMonitor", units="deg")

#create some stimuli
grating = visual.GratingStim(win=mywin, mask="circle", size=3, pos=[-4,0], sf=3)
fixation = visual.GratingStim(win=mywin, size=0.5, pos=[0,0], sf=0, rgb=-1)

#draw the stimuli and update the window

#pause, so you get a chance to see it!

I am on a Mac (most recent version, OS 12.6) using the standalone PsychoPy installation of 2022.2.4. Please let me know if you would need any other information to debug further.


Not sure about the first error you are mentioning, but for the second part I think it is normal that the window appears to freeze because you have the core.wait(5.0) funtion in there. Could you try to add mywin.close() below that and run the script to see if it closes the window after 5 seconds?

It sounds like something’s gone wrong when initialising the app, as rather than a reference to the Coder window the app just has None. How did you open PsychoPy? By double clicking a file, or by the icon in launcher?


Thank you both for your replies.

@Christophe_Bossens: Unfortunately, adding the close function does not change the behavior. It seems the window becomes completely unresponsive after the stimuli are presented. Even if I remove the core.wait command, the same behavior persists.

@TParsons: I open the app using the icon in my Applications folder. Is this correct? Does it matter that I have previously tried earlier PsychoPy versions and have also tried to install via Homebrew before?