Python py2exe
概要
サンプルをつくる
Exeにしたいプログラム
- hello.py
print "Hello Py2Exe"
- 実行
C:\work>python hello.py Hello Py2Exe
セットアップスクリプト
- setup.py
from distutils.core import setup import py2exe setup(console=['hello.py'])
セットアップスクリプトの実行
C:\work\python setup.py py2exe C:\Python26\lib\site-packages\py2exe\build_exe.py:16: DeprecationWarning: the sets module is deprecated import sets running py2exe creating C:\work\build : (略) : creating C:\work\dist *** searching for required modules *** *** parsing results *** creating python loader for extension 'select' (C:\Python26\DLLs\select.pyd -> select.pyd) creating python loader for extension 'unicodedata' (C:\Python26\DLLs\unicodedata.pyd -> unicodedata.pyd) creating python loader for extension 'bz2' (C:\Python26\DLLs\bz2.pyd -> bz2.pyd) *** finding dlls needed *** *** create binaries *** *** byte compile python files *** byte-compiling C:\Python26\lib\StringIO.py to StringIO.pyc byte-compiling C:\Python26\lib\UserDict.py to UserDict.pyc : (略) : copying C:\Python26\DLLs\unicodedata.pyd -> C:\work\dist *** copy dlls *** copying C:\WINDOWS\system32\python26.dll -> C:\work\dist setting sys.winver for 'C:\work\dist\python26.dll' to 'py2exe' copying C:\Python26\w9xpopen.exe -> C:\work\dist copying C:\Python26\lib\site-packages\py2exe\run.exe -> C:\work\dist\hello.exe *** binary dependencies *** Your executable(s) also depend on these dlls which are not included, you may or may not need to distribute them. Make sure you have the license if you distribute any of them, and make sure you don't distribute files belonging to the operating system. WSOCK32.dll - C:\WINDOWS\system32\WSOCK32.dll USER32.dll - C:\WINDOWS\system32\USER32.dll ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll
構成
- C:\work ここで作業する
<<ref_imageプラグインは存在しません。>>
- dist、build ディレクトリが作成される
配布用
- C:\work\dist に配布用パッケージが作成される
<<ref_imageプラグインは存在しません。>>
- exe 単体では動かない。
実行
<<ref_imageプラグインは存在しません。>>

YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto
Copyright© 矢木 浩人 All Rights Reserved.