Py2exe for Python 3.0
I am looking for a Python3.0 version of «py2exe». I tried running 2to3 on the source for py2exe but the code remained broken. Any ideas?
32.3k 14 14 gold badges 83 83 silver badges 96 96 bronze badges
asked Feb 2, 2009 at 22:28
321 1 1 gold badge 3 3 silver badges 4 4 bronze badges
If you’re relying on 3rd party modules, you might be better off waiting a while before moving to python 3.0.
Feb 2, 2009 at 23:08
Please update your question to make it easier to understand. You are looking for a python 3.0 version of p`y2exe, right?
Feb 3, 2009 at 9:32
I guess it would be called py3exe
Oct 15, 2013 at 21:12
5 Answers 5
Update 2014-05-15
py2exe for Python 3.x is now released! Get it on PyPI.
Old information
Have a look at the py2exe SourceForge project SVN repository at:
The last I looked at it, it said the last update was August 2009. But keep an eye on that to see if there’s any Python 3 work in-progress.
I’ve also submitted two feature requests on the py2exe tracker. So far, no feedback on them:
1 1 1 silver badge
answered Mar 11, 2009 at 7:33
Craig McQueen Craig McQueen
42k 30 30 gold badges 132 132 silver badges 181 181 bronze badges
Did you check out cx_Freeze? It seems to create standalone executables from your Python scripts, including support for Python 3.0 and 3.1
26.5k 28 28 gold badges 123 123 silver badges 181 181 bronze badges
answered Aug 11, 2009 at 22:00
1,433 1 1 gold badge 22 22 silver badges 30 30 bronze badges
Will it run on Ubuntu 64 bit?
Aug 11, 2009 at 23:52
It runs on Ubuntu, but it generates Linux executables, not Windows executables. You can run it on WINE, but then you may need to copy some DLLs in manually.
Feb 11, 2012 at 19:42
py2exe for Python3 is out!
Note that py2exe for Python 3 only supports Python 3.3 and above!
A huge thank you to the py2exe development team!
answered May 13, 2014 at 18:15
dotancohen dotancohen
30.4k 39 39 gold badges 140 140 silver badges 197 197 bronze badges
The py2exe and 2to3 programs serve completely different purposes, so I’m not sure what your ultimate goal is.
If you want to build an executable from a working Python program, use the version of py2exe that is suitable for whichever Python you are using (version 2 or version 3).
If you want to convert an existing Python 2 program to Python 3, use 2to3 plus any additional editing as necessary. The Python 3 documentation describes the conversion process in more detail.
Update: I now understand that you might have been trying to run 2to3 against py2exe itself to try to make a Python 3 compatible version. Unfortunately, this is definitely beyond the capabilities of 2to3 . You will probably have to wait for the py2exe project to release a Python 3 compatible version.
Python executables: py2exe or PyInstaller?
To create executable files (windows) I assume that we should use one of them: Py2exe or PyInstaller. What are the difference between them?
asked Jun 2, 2011 at 9:50
33.6k 47 47 gold badges 192 192 silver badges 273 273 bronze badges
3 Answers 3
Py2exe and PyInstaller both are wrappers but here are few differences that I noticed,
- Py2exe is compatible with python2.4+ including python3.0 & 3.1 whereas PyInstaller is currently, compatible with python 2.7 and 3.3–3.5
- As far I know, Py2exe didn’t support signing whereas Pyinstaller has support for signing from version 1.4
- In PyInstaller it is easy to create one exe, By default both create a bunch of exes & dlls.
- In py2exe its easier to embed manifest file in exe, useful for run as administrator mode in windows vista and beyond.
- Pyinstaller is modular and has a feature of hooks to include files in the build that you like. I don’t know about this feature in py2exe.
Hope this helps you in your decision making.
py2exe — generate single executable file
I thought I heard that py2exe was able to do this, but I never figured it out. Has anyone successfully done this? Can I see your setup.py file, and what command line options you used? Basically I’m thinking of it giving me a single executable file that does something like unzips itself to maybe /temp and runs.
42k 15 15 gold badges 74 74 silver badges 90 90 bronze badges
asked Sep 22, 2008 at 0:49
45.7k 89 89 gold badges 232 232 silver badges 297 297 bronze badges
8 Answers 8
The way to do this using py2exe is to use the bundle_files option in your setup.py file. For a single file you will want to set bundle_files to 1, compressed to True, and set the zipfile option to None. That way it creates one compressed file for easy distribution.
Here is a more complete description of the bundle_file option quoted directly from the py2exe site*
- 3 (default) don’t bundle
- 2 bundle everything but the Python interpreter
- 1 bundle everything, including the Python interpreter
Here is a sample setup.py:
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = >, windows = [], zipfile = None, )
1 1 1 silver badge
answered Sep 22, 2008 at 3:19
22.3k 40 40 gold badges 90 90 silver badges 106 106 bronze badges
Sure if you want only the interpreter not bundled then choose 2 for the bundle_files option. Good luck!
Aug 10, 2009 at 17:36
Please note that bundle_files 1 isn’t supported on amd64 (py2exe 0.6.9 for Python 2.6 at least)
Mar 8, 2011 at 17:20
Not exactly a single executable, as you need to install the Microsoft Visual C runtime DLL.
Sep 28, 2012 at 13:56
I had a console application that I wanted to have as a single executable. I had to replace windows = [<'script': "single.py">] with console = [‘single.py’] so double-clicking the file would open in a CMD window in Windows.'script':>
Jul 9, 2014 at 16:08
6 years since @Joril’s comment and still — «error: bundle-files 1 not yet supported on win64»
Mar 19, 2017 at 15:13
PyInstaller will create a single .exe file with no dependencies; use the —onefile option. It does this by packing all the needed shared libs into the executable, and unpacking them before it runs, just as you describe (EDIT: py2exe also has this feature, see minty’s answer)
I use the version of PyInstaller from svn, since the latest release (1.3) is somewhat outdated. It’s been working really well for an app which depends on PyQt, PyQwt, numpy, scipy and a few more.
1 1 1 silver badge
answered Sep 22, 2008 at 0:55
74.4k 30 30 gold badges 131 131 silver badges 136 136 bronze badges
I found py2exe worked a lot better than pyInstaller, when you’re using eggs. minty’s answer is the solution.
Jul 30, 2009 at 10:23
Please note that as of version 1.4, PyInstaller doesn’t support Python 2.6+ on Windows
Mar 9, 2011 at 8:08
I am now using version 1.5.1, and it works with Python 2.7.2.
Jan 2, 2012 at 3:35
py2exe can create a single file executable if you specify a few arguments in the compiler program. py2exe has a tutorial for single file executables online.
Dec 9, 2013 at 21:41
Objective Viewpoint: I do not see how this is an acceptable answer since it does not address the question of creating a single exe file with py2exe. (Nonetheless, this is a useful answer of course.)
May 15, 2015 at 11:24
As the other poster mention, py2exe , will generate an executable + some libraries to load. You can also have some data to add to your program.
Next step is to use an installer, to package all this into one easy-to-use installable/unistallable program.
I have used InnoSetup with delight for several years and for commercial programs, so I heartily recommend it.
722 9 9 silver badges 15 15 bronze badges
answered Dec 2, 2008 at 9:44
Philippe F Philippe F
11.8k 5 5 gold badges 30 30 silver badges 30 30 bronze badges
+1 for indicating that after py2exe still there are things to package.
Dec 18, 2011 at 8:48
I’ve been able to create a single exe file with all resources embeded into the exe. I’m building on windows. so that will explain some of the os.system calls i’m using.
First I tried converting all my images into bitmats and then all my data files into text strings. but this caused the final exe to be very very large.
After googleing for a week i figured out how to alter py2exe script to meet my needs.
here is the patch link on sourceforge i submitted, please post comments so we can get it included in the next distribution.
this explanes all the changes made, i’ve simply added a new option to the setup line. here is my setup.py.
i’ll try to comment it as best I can. Please know that my setup.py is complex do to the fact that i’m access the images by filename. so I must store a list to keep track of them.
this is from a want-to-b screen saver I was trying to make.
I use exec to generate my setup at run time, its easyer to cut and paste like that.
exec "setup(console=[],\ options=,\ zipfile = None )" % (bitmap_string[:-1])
script = py script i want to turn to an exe
icon_resources = the icon for the exe
file_resources = files I want to embed into the exe
other_resources = a string to embed into the exe, in this case a file list.
options = py2exe options for creating everything into one exe file
bitmap_strings = a list of files to include
Please note that file_resources is not a valid option untill you edit your py2exe.py file as described in the link above.
first time i’ve tried to post code on this site, if I get it wrong don’t flame me.
from distutils.core import setup import py2exe #@UnusedImport import os #delete the old build drive os.system("rmdir /s /q dist") #setup my option for single file output py2exe_options = dict( ascii=True, # Exclude encodings excludes=['_ssl', # Exclude _ssl 'pyreadline', 'difflib', 'doctest', 'locale', 'optparse', 'pickle', 'calendar', 'pbd', 'unittest', 'inspect'], # Exclude standard library dll_excludes=['msvcr71.dll', 'w9xpopen.exe', 'API-MS-Win-Core-LocalRegistry-L1-1-0.dll', 'API-MS-Win-Core-ProcessThreads-L1-1-0.dll', 'API-MS-Win-Security-Base-L1-1-0.dll', 'KERNELBASE.dll', 'POWRPROF.dll', ], #compressed=None, # Compress library.zip bundle_files = 1, optimize = 2 ) #storage for the images bitmap_string = '' resource_string = '' index = 0 print "compile image list" for image_name in os.listdir('images/'): if image_name.endswith('.jpg'): bitmap_string += "( " + str(index+1) + "," + "'" + 'images/' + image_name + "')," resource_string += image_name + " " index += 1 print "Starting build\n" exec "setup(console=[],\ options=,\ zipfile = None )" % (bitmap_string[:-1]) print "Removing Trash" os.system("rmdir /s /q build") os.system("del /q *.pyc") print "Build Complete"
ok, thats it for the setup.py now the magic needed access the images. I developed this app without py2exe in mind then added it later. so you’ll see access for both situations. if the image folder can’t be found it tries to pull the images from the exe resources. the code will explain it. this is part of my sprite class and it uses a directx. but you can use any api you want or just access the raw data. doesn’t matter.
def init(self): frame = self.env.frame use_resource_builtin = True if os.path.isdir(SPRITES_FOLDER): use_resource_builtin = False else: image_list = LoadResource(0, u'INDEX', 1).split(' ') for (model, file) in SPRITES.items(): texture = POINTER(IDirect3DTexture9)() if use_resource_builtin: data = LoadResource(0, win32con.RT_RCDATA, image_list.index(file)+1) #windll.kernel32.FindResourceW(hmod,typersc,idrsc) d3dxdll.D3DXCreateTextureFromFileInMemory(frame.device, #Pointer to an IDirect3DDevice9 interface data, #Pointer to the file in memory len(data), #Size of the file in memory byref(texture)) #ppTexture else: d3dxdll.D3DXCreateTextureFromFileA(frame.device, #@UndefinedVariable SPRITES_FOLDER + file, byref(texture)) self.model_sprites[model] = texture #else: # raise Exception("'sprites' folder is not present!")
Any questions fell free to ask.
Saved searches
Use saved searches to filter your results more quickly
Cancel Create saved search
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
py2exe / py2exe Public
Create standalone Windows programs from Python code
License
Unknown, MPL-2.0 licenses found
Licenses found
LICENSE.txt
MPL2-License.txt
py2exe/py2exe
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch branches/tags
Branches Tags
Could not load branches
Nothing to show
Could not load tags
Nothing to show
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Cancel Create
- Local
- Codespaces
HTTPS GitHub CLI
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more about the CLI.
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
4e7b2b2 Oct 8, 2023
… frozen binaries.
Git stats
Files
Failed to load latest commit information.
Latest commit message
Commit time
October 29, 2022 16:17
October 8, 2023 16:56
October 8, 2023 16:56
January 27, 2023 12:02
October 8, 2023 16:56
September 4, 2022 22:51
March 11, 2019 14:29
October 20, 2020 23:09
March 11, 2019 14:29
April 3, 2021 11:28
October 3, 2020 18:49
October 7, 2023 19:10
March 11, 2019 14:33
October 24, 2020 23:00
March 11, 2019 14:29
March 11, 2019 14:29
September 18, 2022 10:37
October 7, 2023 19:13
October 7, 2023 19:13
September 18, 2022 10:38
README.md
py2exe for Python 3
py2exe is a software to build standalone Windows executable programs from Python scripts. py2exe can build console executables and windows (GUI) executables. py2exe supports the Python versions* included in the official development cycle.
Development of py2exe is hosted here: https://github.com/py2exe/py2exe.
The detailed changelog is published on GitHub.
- improved the hook for pkg_resources to detect its vendored content automatically
- the matplotlib hook now does not exclude wx automatically
- adapted the hook for matplotlib to support their use of delvewheel
- adapted the hooks for numpy and pandas to support the new .libs location
- Add support for Python 3.11
- Drop support for Python 3.7
- Drop support for win32 wheels
- win32 wheels are still built and shipped but are provided untested. Issues experienced when using these wheels will not be investigated. See #157 for further information.
- Support scipy versions newer than 1.9.2.
- Fixed documentation for the py2exe.freeze API.
- Fixed an issue that prevented builds via the deprecated setup.py API.
- Introduce the new py2exe.freeze API. Documentation can be found here.
- Use of the setup.py py2exe command and of distutils is deprecated as per PEP 632. Both these interfaces will be removed in the next major release. See here for a migration guide.
- Add two hooks to fix the bundling of winrt and passlib .
- The log file for windows apps is now stored in %APPDATA% by default
- ModuleFinder now raises an explicit error if a required module is in excludes
- Restore hook functionality for pkg_resources
- The Stderr.write method used for windows apps now returns the number of written bytes
- Drop support for Python 3.6
- Include package metadata in the bundle archive (to be used by e.g. importlib.metadata )
- Fixed a bug that prevented to use the optimize option when six was in the bundle
- Fixed a bug that ignored the optimize flag for some packages
- Show again relative paths in Tracebacks that happen from the frozen application (#12 and #114)
- New module finder mf310 written as a wrapper around CPython modulefinder.ModuleFinder
- Add support for Python 3.10
- New hook for scipy
- zipextimporter can now be built as a standalone extension via its own setup script
- ModuleFinder : add support for the pkg_resources.extern.VendorImporter loader
- New hooks for pkg_resources and infi
- zipextimporter supports external modules that use multi-phase initialization (PEP 489)
- New hook for selenium
- dllfinder provides a new method to add data files in the zip archive
- New hook for pycryptodomex
- ModuleFinder : respect excludes list in import_package
- Updated hook for matplotlib >= 3.4.0
- New hook for supporting matplotlib 3.2 and higher.
- Fix for including implicit namespace packages as per PEP420.
- Patch MyLoadLibrary to support ssl with bundle_files=0 .
- New module finder with support for implicit namespace packages (PEP 420).
- DLLFinder automatically excludes VC++ redist and Windows CRT DLLs from bundles.
- Several fixes for bundling software with bundle_files
- New hooks for pycryptodome and shapely .
- Add support for Python 3.9.
- Drop support for Python 3.5.
- New hooks for urllib3 and pandas .
Version 0.10.0.2 (from versions 0.9.x):
- Introduce compatibility with Python 3.5, 3.6, 3.7, and 3.8.
- Drop compatibility with Python 3.4 and earlier.
- New or updated hooks for certifi , numpy , tkinter , socket , ssl , and six .
- build_exe : the zipfile=None option has been removed.
- runtime : the Python interpreter DLL is no longer altered before being inserted in the executable bundle.
- Several bugfixes, better error messages.
pip install py2exe
Use the py2exe.freeze function as documented here.
Using a setup.py script or the builder
Using a setup.py script with py2exe is deprecated. Please adapt your scripts to use the new freeze API. This interface will be removed in the next major release.
The build_exe (or -m py2exe ) CLI was removed in version 0.13.0.0.
Known issues and notes
- High-level methods or hooks to embed Qt plugins in the bundle (needed by PySide2/PyQt5) are missing.
- (*) win32 wheels are provided without testing. Users are encouraged to use the win_amd64 wheels (see #157).
Further informations about the original development of py2exe and other usage guidelines can be found in the original README.
About
Create standalone Windows programs from Python code
