1

I have written a python code which displays a window using Tkinter. It also calls another python file present in the same folder. I converted the .py files into a .exe file using py2exe. But i am facing the below issues:

  1. The output (in dist folder) is a set of files and not a single executable file.

    • As per my understanding using the 'bundle_files':1,'compressed':True, i should be getting a single file.
    • Now i have two .exe files and 1 folder: w9xpopen.exe,myframe.py(this is my file) and folder "tcl"
  2. The icon is not changed.

    • I had mentioned "icon_resources":[(0,"icon.ico")] in the "windows" section

Below is the setup.py i used:

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

sys.argv.append('py2exe')

setup(

  options={'py2exe':{'bundle_files':1,'compressed':True}},
  windows=[{"script":'hr_data_downloader.py',"icon_resources":   [(0,"icon.ico")]}],
 data_files = [],
 zipfile=None
)

I had issues running the executable at first but after going through the below posts, i corrected it by explicitly adding the two dlls.

Creating single EXE using py2exe for a Tkinter program

py2exe - generate single executable file

Please let me know if it is possible to create a single-file executable by modifying the setup files or any other py2exe files. Also please tell me why the icon is not shown for the created .exe

I am open to try other distribution utilities like py2exe if it can help me create single-file executable.

Community
  • 1
  • 1
newbieuser
  • 81
  • 1
  • 2
  • 9

2 Answers2

2

I figured out how to do it using pyinistaller. Although it makes the exe considerably large, i am happy that i have only single file.

Below is what i did:

  1. Installed pyinstaller, pywin32
  2. Open command prompt
  3. go to my code folder
  4. use command pyinstaller --onefile --windowed myframe.py

The manual for pyinstaller has detailed explanations.

newbieuser
  • 81
  • 1
  • 2
  • 9
0

Pyinstaller can be used to generate a single executable file from a python project.
STEP 1 :
Install Pyinstaller
https://www.pyinstaller.org/downloads.html
https://github.com/pyinstaller/pyinstaller/zipball/develop

STEP 2 :
Extract the file in python installed directory (C:\Python27\)
Remane the extracted folder to : pyinstaller
STEP 3 :
Now open command prompt in Python directory and
use command : cd pyinstaller
(To create exe)
use command : python pyinstaller.py your_python_file.py
(To create single exe)
use command : python pyinstaller.py --onefile --windowed your_python_file.py (your_python_file.py : it should be placed in C:\Python27\pyinstaller\)

Output Folde : C:\Python27\pyinstaller\main\dist