我不能用pyinstaller生成.exe,也不能用autopytoexe生成它给我的无法执行脚本消息

2024-10-04 01:34:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我制作了一个机器人,它做一些图像处理的事情,并给我一些值,但我不能将.py转换为.exe来运行每个窗口。我正在使用这些库

import tkinter as tk
import time
import threading
import pywinauto
from PIL import Image, ImageGrab
import cv2
import pytesseract

我的代码也使用这样的特定路径

def takeSnapShot(sFileName):
try:

    imagee = ImageGrab.grab()
    name = sFileName + ".jpg"
    imagee.save(name, 'JPEG', quality=2880)

except:
    print("Error!")


def sayioku():
    takeSnapShot(r"D:\klasor\gelen")

    img = cv2.imread(r"D:\klasor\gelen.jpg")
    img_crop = img[120:168, 1377:1422]
    cv2.imwrite(r'D:\klasor\gelencroped.jpg', img_crop)
    img = Image.open(r'D:\klasor\gelencroped.jpg')

    thresh = 200
    fn = lambda x: 0 if x > thresh else 255
    r = img.convert('L').point(fn, mode='1')
    r.save(r'D:\klasor\gelenblackandwhite.jpg', quality=95)
    im = Image.open(r'D:\klasor\gelenblackandwhite.jpg')

    pytesseract.pytesseract.tesseract_cmd = r'D:\teseract\tesseract.exe'
    data = pytesseract.image_to_string(im, lang='eng', config='--psm 10 --oem 3 -c tessedit_char_whitelist=0123456789')
    try:
        kata = int(data)

    except:
        print('This is not integer')
    return kata

我使用3个图像作为附件,我也使用tkinter作为GUI,线程在GUI中运行我的while循环而不会过载。它适用于简单的库和代码,但在我的例子中我无法理解

我使用这个链接来生成.exe

https://www.youtube.com/watch?v=t51bT7WbeCM&t=66s
https://www.youtube.com/watch?v=jfs_WJiJOUU&t=651s
https://www.youtube.com/watch?v=8pNwpy5bnBU
https://stackoverflow.com/questions/34453458/how-to-use-pyinstaller

此错误消息提示我正在使用pyinstaller。如果我按照链接3的步骤操作,它会给我一条执行脚本错误消息

appdata\local\programs\python\python38-32\lib\site-
packages\win32com\client\makepy.py:369: SyntaxWarning: "is not" with a 
literal. Did you mean "!="?
if path is not '' and not os.path.exists(path):

我需要为所有用户更改这些路径。如何确保所有用户具有相同的路径或自动更改用户的路径


Tags: httpsimageimport路径comimgyoutubeis