Here\'s the code that I\'m trying to run:
import pyautogui r=pyautogui.locateOnScreen(\'C:\\Users\\David\\Desktop\\index.png\',grayscale=False) print r
I had the similar problem.
My fault was I had saved the compare picture as jpg first and then as png in MS paint.
Be sure to save the compare picture as png format. After this the Locate function worked for me.