【问题标题】:Build multiple files like .py .png in a single file在单个文件中构建多个文件,例如 .py .png
【发布时间】: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


    【解决方案1】:

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

    您需要将名为“img.PNG”的图像与exe文件放在同一文件夹中,然后它才能工作

    【讨论】:

      猜你喜欢
      • 2018-12-29
      • 2021-10-16
      • 1970-01-01
      • 2020-07-20
      • 2010-10-19
      • 1970-01-01
      • 2011-06-13
      • 1970-01-01
      • 2023-02-01
      相关资源
      最近更新 更多