0

I made a bot that does some stuff with image processing and gives me values but I can't convert .py to .exe for running every windows. I am using these libraries.

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

Also my codes using a specific path like this

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

I am using 3 images as an attachment also I am using tkinter as GUI, threading to work my while loop inside GUI without overload. It works fine with simple libraries and codes but I couldn't figure it out in my case.

I used this links to make .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

This error message gives me using pyinstaller. If I follow to steps of link 3 it gives me Execute script error message

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):

I need to change these paths for all users. How can I make sure all users have the same path or change the path for users automatically.

Efe
  • 88
  • 1
  • 7
  • 1
    Maybe the images aren't in the compiled package, and therefore it cannot access them? – TheTechRobo the Nerd May 25 '20 at 17:30
  • “I can’t convert .py to .exe” - do you mean that the exe won’t run or that you can’t create the exe due to an error from pyinstaller? Please edit the _full__ error message into your answer. – DisappointedByUnaccountableMod May 25 '20 at 17:45
  • "Failed to execute script example." You can see an example in the 3rd link also and my images keep changing every 3 sec. It is taking snapshots and cropping them, doing a binary image, and trying to figure it out values. At the beginning of the start, there is no image. It is taking snapshots constantly and using them – Efe May 25 '20 at 17:57
  • I don’t want to click links - please edit the text of the links _into the question_. – DisappointedByUnaccountableMod May 25 '20 at 18:07
  • And you still haven’t given full details of what the actual error is - please edit the full error message into your question. – DisappointedByUnaccountableMod May 25 '20 at 18:08
  • Changed it. I can't describe videos as a text. – Efe May 25 '20 at 18:40
  • So the `import pyautogui` is giving the error. Looks like a duplicate of https://stackoverflow.com/questions/53121157/pyautogui-module-missing-from-executable-file-made-with-pyinstaller because pyinstaller doesn’t support pyautogui - suggestion in that q/a is to use pywinauto which is supported. Found this using a popular search engine to look for nothing more complicated than _pyinstaller pyautogui_ – DisappointedByUnaccountableMod May 25 '20 at 19:55

0 Answers0