0

py2exe's been driving me insane.

I'm trying to bundle a small app that has no GUI or anything and even though I am not using TKinter, py2exe keeps wanting to bundle it in the .exe.

I'm a beginner in all this so if the my app code is not that great, that's the reason.

Below is my code

from PIL import Image
import glob
import os
file_types = ("*.jpg", "*.jpeg", "*.tif", "*.tiff", "*.png", "*.bmp")

image_list = []

for images in file_types :
    image_list.extend(glob.glob(images))

maxW = 1920
maxH = 1920

def ResizeImages(image_list) :
    if not os.path.exists("done") :
        os.makedirs("done")

    for image in image_list :
        img = Image.open(image)
        imgnoext = os.path.splitext(image)[0]
        width = img.size[0]
        height = img.size[1]
        ratio = float(width) / float(height)
        if width > maxW :
            height = int(maxW / ratio)
            resized = img.resize((maxW,height), Image.ANTIALIAS)
            resized.save("done/" + imgnoext + ".jpg", format="JPEG", quality=90)
        elif height > maxH :
            width = int(maxW * ratio)
            resized = img.resize((width,maxH), Image.ANTIALIAS)
            resized.save("done/" + imgnoext + ".jpg", format="JPEG", quality=90)
        else :
            img.save("done/" + imgnoext + ".jpg", format="JPEG", quality=90)

ResizeImages(image_list)

And this is the setup.py

from distutils.core import setup
import py2exe, sys, os

sys.argv.append('py2exe')

setup(
    options = {
        'py2exe': {'bundle_files': 1, 'compressed': True}},
    console = [{'script': "resize.py"}],
    zipfile = None
)

And every time I try to bundle it, this happens:

running py2exe

  11 missing Modules                 
  ------------------                 
? PIL._imagingagg                     imported from PIL.ImageDraw
? PyQt4                               imported from PIL.ImageQt
? PyQt5                               imported from PIL.ImageQt
? PySide                              imported from PIL.ImageQt
? _grabscreen                         imported from PIL.ImageGrab
? _imaging_gif                        imported from PIL.GifImagePlugin
? _util                               imported from PIL.ImageCms
? cffi                                imported from PIL.Image, PIL.PyAccess
? readline                            imported from cmd, code, pdb
? win32api                            imported from platform
? win32con                            imported from platform
OOPS: tkinter 2

What am I doing wrong? I need to bundle this so that it will run on any Windows machine, with or without Python installed.

Faryus
  • 161
  • 1
  • 4
  • 14

1 Answers1

0

I've tried and tried, and was not able to bundle this using py2exe.

If someone else runs into this problem, just use PyInstaller. It worked the first time, with no issues.

Faryus
  • 161
  • 1
  • 4
  • 14