1

I want to generate for Windows platform the executable file of my Python GUI application.
- I'm using two .py OO scripts
- The first script (processcls.py) contains this header:

from lxml import html
from urllib import urlopen
import os, re, sys, time

- The second script contains this header:

from processcls import *
from Tkinter import *
import Queue, threading, tkFileDialog, ttk, tkMessageBox, win32clipboard

- And this is my py2exe script. The problem is that I can't see any GUI created. So I don't clear know where is my mistake in the code.

from distutils.core import setup
import py2exe
setup(
    name='MyApplic',
    author='amazon',
    author_email='[email protected]',
    windows=[
        {
            'script':"init.py",
            'uac_info': "requireAdministrator","icon_resources": [(1, "favicon.ico")]
        }
    ], 
    options=
        {
            'py2exe':{
                'includes': ['lxml.etree', 'lxml._elementpath', 'gzip', 'processcls'],
                'packages': ['lxml', 'urllib', 'Tkinter'],
                'bundle_files': 1,
                'compressed'  : True
        }
    },
    zipfile = None
)

Any suggestions? I'm using Tkinter as a GUI gramework and Python 2.7

Thanks Migrome

12
  • 1
    There are several other questions on using tkinter with py2exe. Have you checked any of them? Also although this doesn't answer your question I would recommend trying out PyInstaller instead. py2exe is no longer actively maintained and PyInstaller, its spiritual successor, is a little easier to use IMO. Commented Dec 11, 2013 at 17:53
  • Thanks. In fact there are some other questions about Tkinter but not with Tkinter+Py2exe, not specifically about the problem I have. Let me try PyInstaller and I will comment. Commented Dec 11, 2013 at 17:57
  • @Iguananaut - Py2exe is most definitely still maintained. Thomas Heller deals with it over at SourceForge, and I know for a fact that an update is in the works that will include (among other things) support for bundle_files on 64-bit installs. Commented Dec 11, 2013 at 19:24
  • @MigRome - Also worth noting - pyinstaller uses 2-pass execution (extract to temp folder, run extracted program, clean up temp folder) for every launch of your program. Depending on what your program does and whether it will be run repeatedly, that can cause severe disk overhead. Commented Dec 11, 2013 at 19:29
  • 1
    When you run python setup.py py2exe are there any errors? Commented Dec 11, 2013 at 19:49

2 Answers 2

3

go to cmd and type

pip install auto-py-to-exe

wait until it finishes, and then, run

auto-py-to-exe

on cmd. A GUI should appear. Follow the instructions given.

Sign up to request clarification or add additional context in comments.

Comments

1

All credits to https://www.youtube.com/watch?v=OZSZHmWSOeM

If you are unable to run the pip command, follow this guide:

  1. Download this zip: https://github.com/brentvollebregt/auto-py-to-exe
  2. Extarct the zip file.
  3. In the cmd, browse to the main folder of the program, in my case C:\Program Files\auto py to exe:

    cd C:\Program Files\auto py to exe

  4. Install the repository using this command (continue in the cmd):

    pip install -r requirements.txt

  5. When finished, run the run.py file from the same folder or just type in the cmd: (Tip: Create a shortcut for this file to the desktop for future usage!)

    python run.py

An "Auto Py To Exe" GUI should appear in the screen.

  1. Select your .py file or paste the path on "Script Location"

  2. Select One File mode.

  3. If you are using a GUI like Tkinter, select "Window Based (Hide the console)". If not, select "Console Based"

  4. Select an icon if you want and select additional files if the code has external files.

  5. In "Advanced", select the output folder.

  6. Click on the "CONVERT .PY TO .EXE" BUTTON. When the process has finished, you'll have a .exe file in your output folder. Execute-it. It should work exactly as the .py other.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.