【发布时间】:2020-08-03 02:14:30
【问题描述】:
我在根目录下有 2 个文件
1 - setup.py
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 不起作用,这意味着它不包含我的 .PNG exe 格式文件。有什么解决办法吗?
【问题讨论】:
标签: python python-3.x pyinstaller pyautogui