使用pyinstaller将py转换为exe后它不起作用

发布于 2025-01-10 20:45:47 字数 1265 浏览 3 评论 0原文

我想监控一个区域,但转换后它不起作用。 当我使用cmd发现一些错误时没有任何消息。 当我启动它时,它只会闪烁几分钟,然后就黑了。 它在 python 中运行良好。 请帮忙。 这是代码。

import multiprocessing
from re import A
from PIL import Image
import pytesseract
import time
import threading
from PIL import ImageGrab
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract'
import pyautogui
import keyboard
import winsound
from multiprocessing import Process

def screenshot():
 
    pyautogui.screenshot("C:\\Users\\youngseb\\Desktop\\screenshot1.png", region = region1)
    img1 = Image.open("C:\\Users\\youngseb\\Desktop\\screenshot1.png")
    A1 = pytesseract.image_to_string(img1,lang='kor+eng')
    #print(T)
    strings = A1.split()
    print(strings)
    time.sleep(5)
    pyautogui.screenshot("C:\\Users\\youngseb\\Desktop\\screenshot1.png", region = region1)
    img1 = Image.open("C:\\Users\\youngseb\\Desktop\\screenshot1.png")
    A2 = pytesseract.image_to_string(img1,lang='kor+eng')
    strings = A2.split()
    print(strings)

if (A1 == A2):
    winsound.Beep(2000,500)
    print("ERROR")
else : 
    time.sleep(0.5)
threading.Timer(5, screenshot).start()


if __name__ == '__main__' :
    P1 = Process(target=screenshot)
    P1.start()
    P1.join()


region1 = (572,333,35,15)

I want to monitor one area but after converting it doesn't work.
There is no message when I used cmd to find some error.
when I start it, it just blink few minutes and then black out.
It work well in python.
please help.
here is the code.

import multiprocessing
from re import A
from PIL import Image
import pytesseract
import time
import threading
from PIL import ImageGrab
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract'
import pyautogui
import keyboard
import winsound
from multiprocessing import Process

def screenshot():
 
    pyautogui.screenshot("C:\\Users\\youngseb\\Desktop\\screenshot1.png", region = region1)
    img1 = Image.open("C:\\Users\\youngseb\\Desktop\\screenshot1.png")
    A1 = pytesseract.image_to_string(img1,lang='kor+eng')
    #print(T)
    strings = A1.split()
    print(strings)
    time.sleep(5)
    pyautogui.screenshot("C:\\Users\\youngseb\\Desktop\\screenshot1.png", region = region1)
    img1 = Image.open("C:\\Users\\youngseb\\Desktop\\screenshot1.png")
    A2 = pytesseract.image_to_string(img1,lang='kor+eng')
    strings = A2.split()
    print(strings)

if (A1 == A2):
    winsound.Beep(2000,500)
    print("ERROR")
else : 
    time.sleep(0.5)
threading.Timer(5, screenshot).start()


if __name__ == '__main__' :
    P1 = Process(target=screenshot)
    P1.start()
    P1.join()


region1 = (572,333,35,15)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文