Created
October 31, 2013 13:53
-
-
Save zhuzhuor/7250173 to your computer and use it in GitHub Desktop.
use py2exe to generate a standalone exe file from python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
try: | |
import py2exe | |
except: | |
raw_input('Please install py2exe first...') | |
sys.exit(-1) | |
from distutils.core import setup | |
import shutil | |
sys.argv.append('py2exe') | |
setup( | |
options={ | |
'py2exe': {'bundle_files': 1, 'compressed': True} | |
}, | |
console=[ | |
{'script': "my_program.py"} | |
], | |
zipfile=None, | |
) | |
shutil.move('dist\\my_program.exe', '.\\my_program.exe') | |
shutil.rmtree('build') | |
shutil.rmtree('dist') |
why this extra text is shown in exe file before actual execution?
Traceback (most recent call last):
File "zipextimporter.pyc", line 88, in load_module
File "<frozen zipimport>", line 241, in load_module
File "<frozen zipimport>", line 721, in _get_module_code
zipimport.ZipImportError: can't find module '_ctypes'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "zipextimporter.pyc", line 88, in load_module
File "<frozen zipimport>", line 259, in load_module
File "ctypes\__init__.pyc", line 8, in <module>
File "zipextimporter.pyc", line 112, in load_module
ImportError: MemoryLoadLibrary failed loading _ctypes.pyd: The specified module could not be found. (126)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "boot_common.py", line 46, in <module>
File "zipextimporter.pyc", line 121, in load_module
zipimport.ZipImportError: can't find module ctypes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very thanks, working using python 3.4.3 in windows 7