Problem running experiment coded on Spyder (Macbook pro M1 13)

Dear community,

I have recently acquired a new mac laptop (MacBook Pro (13-inch, M1, 2020) with OS Monterrey 12.3.1 installed).

I am trying to run an “old” experiment in this new computer, however, when I launch it, after opening the drawing screen, the screen becomes black and the terminal returns the following error several times:

2022-04-25 14:09:03.963 python[21374:171669] Warning: Expected min height of view: (<NSPopoverTouchBarItemButton: 0x7fa01d1c7410>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.

2022-04-25 14:09:03.964 python[21374:171669] Warning: Expected min height of view: (<NSButton: 0x7fa01f08d310>) to be less than or equal to 30 but got a height of 32.000000. This error will be logged once per view in violation.

I am running the experiment in a conda environment with Python 3.7 (given that I could not install Psychopy via pip command under the latest Python version, due to a problem with version incompatibilities with Sphinx).
I have tried to install different Psychopy versions (now I am using ‘2021.2.0’), but I always receive the same error. I will continue doing more test to see if I can isolate the problem, anyways, I would appreciate if someone could give me a hint to solve it.

PD: I have just found that if I dont use fullscreen mode and I draw on a window, I still receive the same error messages but I can see the stimuli drawn (although the timing is really bad, perhaps because frame rate when drawing on a window is not precise). In any case, I would like to figure out how to draw in fullscreen.

Thank you very much,


Are there here other users implementing psychopy in spyder using the same hardware & OS without issues?


Do you have any external monitors connected? If it’s only displayed when not full screen, it may be that it’s displaying on the wrong monitor, potentially your laptop screen if you have it set up so your laptop is closed and you use an external monitor? Could also be that your macbook is listing the touch bar as a screen so PsychoPy is trying to run the experiment on it, which would obviously not work.

Thanks for your answer,

I get the same error with and without an external display connected to my laptop.

In relation to psychopy listening from the touchbar, I also thought about that possibility. Nevertheless it is weird because I am able to draw the stimuli in the correct monitor (when it is not fullscreen, but there is a problem with the timings). Not sure if perhaps psychopy is reading some screen attributes from the touchbar (although correctly drawing in the right screen), and that is giving the error.
I am starting also to believe that there might me some incompatibilities with the last OSX update (Monterrey), as I have other colleges that own other Macs (without touchbar, or even with an intel processor) experiencing issues with psychopy. That is why I am curious to know whether there is other people running psychopy in the last monterrey version without problems.


@jon (as a habitual Mac user :wink: ) has been looking deeper into this and has found something in the code for pyglet, the backend which PsychoPy uses to create a window, which suggests it may struggle to identify the correct screen in some specific setups. There are other options for the window backend in File → Preferences, such as glfw, do you still get this error with other backends?

I think that you are right. If I change the backend then I do not get that error anymore.
Anyways, when I calculate the ifi (inter flip interval) for my screen (60hz) it returns 0.74 instead of 16.66. This problem happens in all the backends. That is weird and makes that drawing timings are a complete mess.

Moreover, when a set pygame or glfw as a default backend, psychopy do not draw the gratings correctly as when I used pyglet. I dont know whether changing the backend should affect the way the stimuli are drawn.

In conclusion, I think that as you suggested, there is something wrong with the macbook pro touchbar. At this moment I am not sure how to solve this problem. As a temporary solution I am going to start coding in another computer using ubuntu.

Thank you very much for helping :slight_smile:

I would agree with @TParsons that it would be worth trying “glfw” (I would avoid pygame). I’m pretty sure the warnings about the touchbar are harmless. I see them constantly (seems to be some issue in pyglet event dispatcher) but I don’t think they impact us in any way.

Regarding the black screen, I’m at a loss. I haven’t seen that myself. Does anything work when fullscreen? Also, could you update to 2022.1.3, which has better error trapping? It might be that there’s some additional genuine error message (rather than the touchbar warnings) that was being missed before.


Oh, regarding conda and spyder, I don’t know if they make any difference. I don’t use them. I would personally avoid using spyder for actually running your studies on the basis that I don’t know what overhead it adds when running scripts (e.g. inserting debugging hooks etc). It might be useful while debugging but run on PsychoPy or from terminal

As soon as I find some time I will try all your suggestions and I will get you back.



I have tried some of the suggested fixes (all these problems replicate in the latests psychopy versions):

In summary, I believe that most of the problem is related with Spyder in mac (not sure if is something general to the OSX update or just my laptop).

When I run the experiment from Spyder, that I typically do for visualising the stimuli online, it only works in window mode.
However, the timing is bad (win.getMsPerFrame(nFrames=60, showVisual=False, msg=’’, msDelay=0.0) returns values of 2 for a 60hz screen instead of 16.66) and I have some slide components that I am not able to click at all.

When I try “glfw”, the window opens even at fullscreen, but it gets frozen (also with fullscreen=false).

Then, I tried to do the same using the standalone version (instead of spyder), and it works almost perfectly. The only problem that I find is something weird that happens with the slider component. It is like the mapping between the visual markers and the mouse cursor do not fully match (e.g. a small movement in the mouse translates to a large displacement of the marker).

All these problems disappear when I test my experiment in a windows computer. In windows, the timings are correct and all the slide components react correctly to the mouse movements. In addition I can open fullscreen both in spyder and it the standalone versions.

I have tried different psychopy versions and I havent seen any new error message. Nevertheless, I am running my experiment in Psychopy 2021.2.3 because there are some circle/ring stimuli that appeared filled in white when I use the latest psychopy version :S Also the slide component is different.

In general, I think that by the moment I have to find an alternative to Spyder for experiment debugging, at least in mac. Coder is a bit limited to test line by line modifications.

Any idea what could be the reason for the mismatched mapping between the slide markers and the mouse cursor?

Thank you for your support.

Can’t help you with the touchbar, as I don’t have one, but I can tell you what I had to do to get Psychopy working with Spyder.

I found I had to make a new conda environment specifically for Psychopy, then install everything that is missing from that environment except Psychopy using conda or mamba. For the very final step, use pip to install Psychopy.

The problem is that pip is less thorough than conda, and can hose installations when you later try to install or update packages using conda. My solution was to pip install Psychopy as the very last step.

I’m running Python 3.9.7 using Spyder 5.1.5, 2021 15-inch M1 MacBook Pro, Monterey 12.4

I searched my Python packages for NSPopoverTouchBarItemButton and got no hits. I’m guessing that the Python graphics engine is retrieving monitor information from MacOS, and the OS is returning NSPopoverTouchBarItemButton (NS = NextStep).

This suggests that you might need to update your Command-Line Tools.