简体   繁体   English

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

[英]Build multiple files like .py .png in a single file

I have 2 files in root我在根目录下有 2 个文件

1 - setup.py 1 - 设置.py

2 - img.PNG 2 - 图像.PNG

code in setup.py is: 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 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.当我直接通过 vs 代码命令行运行此代码时,locateOnScreen 接受一个位于名为“img.PNG”的根文件夹中的参数,它会运行,但是当我使用以下命令通过 pyinstaller 构建文件时。

pyinstaller -F --noupx setup.py

or要么

pyinstaller --onefile setup.py

both commands can build my file into.exe format.这两个命令都可以将我的文件构建成.exe 格式。 but my function locateOnScreen doesn't work, means my it doesn't include my.PNG file in exe format.但是我的 function locateOnScreen 不起作用,这意味着我的它不包含 exe 格式的 my.PNG 文件。 Any solution?任何解决方案?

Yeah pyinstaller doesn't include the png in the exe file, it can't do that, It doesn't include any images.是的,pyinstaller 不在 exe 文件中包含 png,它不能这样做,它不包含任何图像。

You need to put the image called "img.PNG" in the same folder with the exe file then it will work您需要将名为“img.PNG”的图像与 exe 文件放在同一文件夹中,然后它才能工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM