Unable to set Gamma value for window

Whenever I am trying to set gamma value for a window using function setGamma(), psychopy returns the following error:

OSError: The hardware look-up table function (GetDeviceGammaRamp) failed. If you would like to proceed without look-up table (gamma) changes, you can change your defaultGammaFailPolicy in the application preferences. For more information see
https://www.psychopy.org/troubleshooting.html#errors-with-getting-setting-the-gamma-ramp

I have tried the using method of defaultGammaFailPolicy, but it still does not work.

As an alternative solution, I also tried changing the gamma value of the monitor for the window I am currently trying to change the gamma value of, and it did not generate any error, but when I experiment with different gamma values, there isn’t any noticeable change in color when the contrast is 0.

The other issue with this problem is that this problem occurs only when we are using the monitor in extended view. We are currently using 2 monitors in an extended view, but when we set the display setting to be duplicate, setGamma() does not return any error. I am suspecting that the problem may be in identifying the monitor and window, but really have no idea why this error occurs.

If anyone has any idea or insight about how to solve this error, I would appreciate any advice! Thank you!!