GetDeviceGammaRamp failed error on Windows10

OS (e.g. Win10): Win10, update 1909
PsychoPy version (e.g. 1.84.x): 1.90.0
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:
This error occurred when running a task that worked fine on MacOS and Win Vista but failed on Win10
raise AssertionError(‘GetDeviceGammaRamp failed’)
AssertionError: GetDeviceGammaRamp failed
Exception AttributeError: “‘NoneType’ object has no attribute ‘close’” in <bound method Window.del of <psychopy.visual.window.Window object at 0x1C836ED0>> ignored

Background:
This topic put together info from other threads that didn’t entirely solve my problem but provided pieces.
Those threads are here
and here
and here.

It stems from a bug in Win10 update 1903. Microsoft claimed it was solved but apparently that doesn’t apply to the gamma ramp bug. My understanding is that during window creation pyglet attempts to get the gamma ramp from Win10, and according to Microsoft’s bug report “Microsoft has identified some scenarios where gamma ramps, color profiles and night light settings may stop working.”

First steps:
I determined that Win10 Extended Display (PC is attached to a high-res monitor and a low-res projector) caused the error. A single monitor did not.

Solution 1.
A work-around was to use the Display Setting in Win10 of ‘duplicate displays’ instead of ‘extended display’. But this gave poor resolution on my monitor.

Solution 2.
Change the ‘window type’ in PsychoPy’s Builder Preferences from ‘pyglet’ to ‘pygame’. Then the window creation occurs normally without errors. There may be better solutions in later PsychoPy versions (e.g. 3.x has new options) but was the only good solution for v1.90.0.

This topic may be redundant for those who understood the earlier threads, but I hope it clarifies the solution for someone.

Update

Note that in PsychoPy 3.2.4 we’ve reduced the use of the problematic Windows command that has the bug so that this will now only be a problem if you actually need the gamma to be controlled

For most experiments where gamma is not actually needed you can install 3.2.4 and there should be no problem.

If you do need gamma to be controlled then you will need to turn off Extended Monitor mode or use a version of Windows that doesn’t have the bug.