Skip to content Skip to sidebar Skip to footer

Exe Generated By Py2exe And Pyinstaller Not Working

I wrote a screenshot program using python and wanted to compile it as .exe file. So I tried with both py2exe and pyinstaller. My python version is 2.7.14, 32bit. I use Windows 10.

Solution 1:

Solved it!

Below are the modified code for screenshot.py. Run it via py2exe.

from multiprocessing import Process, freeze_support
from PIL import Image
import pyscreenshot as ImageGrab
import time

time.sleep(3)


save_dir = "C:/Users/ling/Downloads/test/"defgrab():
    im = ImageGrab.grab()
    im.save(save_dir + "screenshot.png")

if __name__ == "__main__":
    freeze_support()
    p = Process(target=grab)
    p.start()

It turned out that I need to include freeze_support and Process from multiprocessing

Post a Comment for "Exe Generated By Py2exe And Pyinstaller Not Working"