1

I have 2 files in root

1 - setup.py

2 - img.PNG

code in setup.py is:

import pyautogui, time

print('your screen size is: ', pyautogui.size(),'\n')

time.sleep(3)
foundimage = pyautogui.locateCenterOnScreen('img.PNG', confidence=0.8)

time.sleep(3)
pyautogui.click(foundimage.x + 100, foundimage.y) #click on notes

locateOnScreen takes an argument that is in root folder named "img.PNG" when i run this code directly through vs code commandline, it runs, but when i build files through pyinstaller with following commands.

pyinstaller -F --noupx setup.py

or

pyinstaller --onefile setup.py

both commands can build my file into .exe format. but my function locateOnScreen doesn't work, means my it doesn't include my .PNG file in exe format. Any solution?

1 Answers1

0

Yeah pyinstaller doesn't include the png in the exe file, it can't do that, It doesn't include any images.

You need to put the image called "img.PNG" in the same folder with the exe file then it will work

Ahmed Khaled
  • 308
  • 3
  • 14