Open bishakh17 opened 1 year ago
if this issue is assigned to me, I will be happy to fix it.
I have answered this problem on StackOverflow. I'll pull a new request soon. The original link of my answer is https://stackoverflow.com/questions/76361049/how-to-fix-typeerror-not-supported-between-instances-of-str-and-int-wh/76383784#76383784 I had the same problem when using pyautogui. I'm using Python 3.8, and the version of pyautogui is 9.5.0. Actually, this is a bug in the Python framework packages. I found that Python 3.11 shows the same problem. Anyway, this is how I met this problem and fixed it.
I have this error report:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyscreeze/__init__.py", line 528, in _screenshot_osx if tuple(PIL__version__) < (6, 2, 1): TypeError: '<' not supported between instances of 'str' and 'int'
Then I clicked into this report file and and trace back the value of PILversion. It's defined like this: version = "9.5.0"
Now we find the problem. A simple test program can tell you everything:
__version__ = "9.5.0" print(tuple(__version__)) print(type(tuple(__version__))) print((6, 2, 1)) print(type((6,2,1)))
The output you'll get looks like this:
('9', '.', '5', '.', '0') <class 'tuple'> (6, 2, 1) <class 'tuple'>
They are both tuples, but the elements inside this tuple are str and int types. Of course they can't be compared.
So you need to click into the reported error file. Replace this code:
if tuple(PIL__version__) < (6, 2, 1):
with this code:
if tuple(map(int, PIL__version__.split("."))) < (6, 2, 1):
Now everything should work fine.
Another solution to fix the issue inscript is to add these lines at the top of the file :
import pyscreeze
import PIL
__PIL_TUPLE_VERSION = tuple(int(x) for x in PIL.__version__.split("."))
pyscreeze.PIL__version__ = __PIL_TUPLE_VERSION
It is actually fixed in pyscreeze repo so most relevant fix is just bumping version here. I don't get why you guys want to change PIL version into tuple with ints instead of changing this tupled version into str and just do comparing if PIL__version__ < '6.2.1':
. Any cons of this solution?
I have the same issue still. I'm happy to add a fix and make a PR. @asweigart what's the correct process to get this moving as there are a lot of open issues / PRs?
PyAutoGUI==0.9.54 Pillow==10.0.1 PyScreeze==0.1.29 Mac 13.5.2 (22G91)
when using the screenshot function, I get this error. numScreen = pyautogui.screenshot(region=(640,936,3170-640,1322-936))
line 527, in _screenshot_osx if tuple(PILversion) < (6, 2, 1): TypeError: '<' not supported between instances of 'str' and 'int'