在一个文件中构建多个文件,如.py.png



我在根中有两个文件

1-设置

2-img。PNG-

setup.py中的代码是:

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采用名为"的根文件夹中的参数;img。PNG";当我直接通过vs-code命令行运行此代码时,它会运行,但当我使用以下命令通过pyinstaller构建文件时。

pyinstaller -F --noupx setup.py

pyinstaller --onefile setup.py

这两个命令都可以将我的文件构建为.exe格式。但我的函数locateOnScreen不起作用,这意味着我的函数不包括exe格式的.PNG文件。有什么解决方案吗?

是的,pyinstaller没有在exe文件中包含png,它不能这样做,它不包含任何图像。

您需要将名为";img。PNG";在与exe文件相同的文件夹中,则它将工作

最新更新