asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.47k stars 1.27k forks source link

pyautogui.screenshot() method is not working on Mac OS 13.2.1 #764

Open bwomsm1 opened 1 year ago

bwomsm1 commented 1 year ago

I am facing a problem that started with Mac OS 13.2.1 and was not happening on Mac OS 12.6.3 which that the call to pyautogui.screenshot() is not taking a screen shot.

script to reproduce the problem:

import pyautogui
import numpy
import cv2

images = pyautogui.screenshot()
frames = numpy.array(images)
frames_RGB = cv2.cvtColor(frames, cv2.COLOR_BGR2RGB)

Please advice. Thanks!

RynearsonCode commented 1 year ago

I am running into the same error. It seems that it is due to the pyscreeze init script at line 527: "if tuple(PILversion) < (6, 2, 1):" This code does not support how the PILversion is returned. My version is 10.1.0 but it tuples into(1,0,.,1,.,0). The quickest workaround is to change this line of to: if tuple(map(int, PILversion.split("."))) < (6, 2, 1):

This will convert PIL__version from a str to an int and then tuple is correctly by spliting the number a the periods.

I wouldn't recommend doing this for anything other than testing your code. Someone should make a push request for this fix.

t-robnguyen commented 1 year ago

@RynearsonCode Wow thank you for this. I was running into the same exact issue for max osx.

line 527, in _screenshot_osx if tuple(PILversion) < (6, 2, 1): TypeError: '<' not supported between instances of 'str' and 'int'