| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

「Python py2exe」の版間の差分

提供: MyMemoWiki
ナビゲーションに移動 検索に移動
 
1行目: 1行目:
==Python py2exe ==
+
==[[Python py2exe]] ==
  
 
http://www.py2exe.org/
 
http://www.py2exe.org/
  
 
===概要===
 
===概要===
*PythonスクリプトをWindowsの実行可能プログラムにコンバートすDistutils エクステンション
+
*Pythonスクリプトを[[Windows]]の実行可能プログラムにコンバートすDistutils エクステンション
*Pythonのインストールがなくても実行できるようにする
+
*[[Python]]のインストールがなくても実行できるようにする
 
===サンプルをつくる===
 
===サンプルをつくる===
 
*http://www.py2exe.org/index.cgi/Tutorial#Step1
 
*http://www.py2exe.org/index.cgi/Tutorial#Step1
24行目: 24行目:
 
  C:\work\python setup.py py2exe
 
  C:\work\python setup.py py2exe
 
   
 
   
  C:\Python26\lib\site-packages\py2exe\build_exe.py:16: DeprecationWarning: the sets module is deprecated
+
  C:\[[Python]]26\lib\site-packages\py2exe\build_exe.py:16: DeprecationWarning: the sets module is deprecated
 
   import sets
 
   import sets
 
  running py2exe
 
  running py2exe
34行目: 34行目:
 
  *** searching for required modules ***
 
  *** searching for required modules ***
 
  *** parsing results ***
 
  *** parsing results ***
  creating python loader for extension 'select' (C:\Python26\DLLs\select.pyd -> select.pyd)
+
  creating python loader for extension 'select' (C:\[[Python]]26\DLLs\select.pyd -> select.pyd)
  creating python loader for extension 'unicodedata' (C:\Python26\DLLs\unicodedata.pyd -> unicodedata.pyd)
+
  creating python loader for extension 'unicodedata' (C:\[[Python]]26\DLLs\unicodedata.pyd -> unicodedata.pyd)
  creating python loader for extension 'bz2' (C:\Python26\DLLs\bz2.pyd -> bz2.pyd)
+
  creating python loader for extension 'bz2' (C:\[[Python]]26\DLLs\bz2.pyd -> bz2.pyd)
 
  *** finding dlls needed ***
 
  *** finding dlls needed ***
 
  *** create binaries ***
 
  *** create binaries ***
 
  *** byte compile python files ***
 
  *** byte compile python files ***
  byte-compiling C:\Python26\lib\StringIO.py to StringIO.pyc
+
  byte-compiling C:\[[Python]]26\lib\StringIO.py to StringIO.pyc
  byte-compiling C:\Python26\lib\UserDict.py to UserDict.pyc
+
  byte-compiling C:\[[Python]]26\lib\UserDict.py to UserDict.pyc
 
   :
 
   :
 
  (略)
 
  (略)
 
   :
 
   :
  copying C:\Python26\DLLs\unicodedata.pyd -> C:\work\dist
+
  copying C:\[[Python]]26\DLLs\unicodedata.pyd -> C:\work\dist
 
  *** copy dlls ***
 
  *** copy dlls ***
 
  copying C:\WINDOWS\system32\python26.dll -> C:\work\dist
 
  copying C:\WINDOWS\system32\python26.dll -> C:\work\dist
 
  setting sys.winver for 'C:\work\dist\python26.dll' to 'py2exe'
 
  setting sys.winver for 'C:\work\dist\python26.dll' to 'py2exe'
  copying C:\Python26\w9xpopen.exe -> C:\work\dist
+
  copying C:\[[Python]]26\w9xpopen.exe -> C:\work\dist
  copying C:\Python26\lib\site-packages\py2exe\run.exe -> C:\work\dist\hello.exe
+
  copying C:\[[Python]]26\lib\site-packages\py2exe\run.exe -> C:\work\dist\hello.exe
 
   
 
   
 
  *** binary dependencies ***
 
  *** binary dependencies ***
60行目: 60行目:
 
   
 
   
 
     WSOCK32.dll - C:\WINDOWS\system32\WSOCK32.dll
 
     WSOCK32.dll - C:\WINDOWS\system32\WSOCK32.dll
     USER32.dll - C:\WINDOWS\system32\USER32.dll
+
     USE[[R]]32.dll - C:\WINDOWS\system32\USE[[R]]32.dll
 
     ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
 
     ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
 
     SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
 
     SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
     KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll
+
     KE[[R]]NEL32.dll - C:\WINDOWS\system32\KE[[R]]NEL32.dll
  
 
====構成====
 
====構成====

2020年2月16日 (日) 04:31時点における最新版

Python py2exe

http://www.py2exe.org/

概要

  • PythonスクリプトをWindowsの実行可能プログラムにコンバートすDistutils エクステンション
  • Pythonのインストールがなくても実行できるようにする

サンプルをつくる

Exeにしたいプログラム

hello.py
  1. print "Hello Py2Exe"
実行
  1. C:\work>python hello.py
  2. Hello Py2Exe

セットアップスクリプト

setup.py
  1. from distutils.core import setup
  2. import py2exe
  3.  
  4. setup(console=['hello.py'])

セットアップスクリプトの実行

  1. C:\work\python setup.py py2exe
  2.  
  3. C:\Python26\lib\site-packages\py2exe\build_exe.py:16: DeprecationWarning: the sets module is deprecated
  4. import sets
  5. running py2exe
  6. creating C:\work\build
  7. (略)
  8. creating C:\work\dist
  9. *** searching for required modules ***
  10. *** parsing results ***
  11. creating python loader for extension 'select' (C:\Python26\DLLs\select.pyd -> select.pyd)
  12. creating python loader for extension 'unicodedata' (C:\Python26\DLLs\unicodedata.pyd -> unicodedata.pyd)
  13. creating python loader for extension 'bz2' (C:\Python26\DLLs\bz2.pyd -> bz2.pyd)
  14. *** finding dlls needed ***
  15. *** create binaries ***
  16. *** byte compile python files ***
  17. byte-compiling C:\Python26\lib\StringIO.py to StringIO.pyc
  18. byte-compiling C:\Python26\lib\UserDict.py to UserDict.pyc
  19. (略)
  20. copying C:\Python26\DLLs\unicodedata.pyd -> C:\work\dist
  21. *** copy dlls ***
  22. copying C:\WINDOWS\system32\python26.dll -> C:\work\dist
  23. setting sys.winver for 'C:\work\dist\python26.dll' to 'py2exe'
  24. copying C:\Python26\w9xpopen.exe -> C:\work\dist
  25. copying C:\Python26\lib\site-packages\py2exe\run.exe -> C:\work\dist\hello.exe
  26.  
  27. *** binary dependencies ***
  28. Your executable(s) also depend on these dlls which are not included,
  29. you may or may not need to distribute them.
  30.  
  31. Make sure you have the license if you distribute any of them, and
  32. make sure you don't distribute files belonging to the operating system.
  33.  
  34. WSOCK32.dll - C:\WINDOWS\system32\WSOCK32.dll
  35. USER32.dll - C:\WINDOWS\system32\USER32.dll
  36. ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll
  37. SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll
  38. KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll

構成

C:\work ここで作業する

1060 py2exe01.jpg

  • dist、build ディレクトリが作成される

配布用

C:\work\dist に配布用パッケージが作成される

1061 py2exe02.jpg

  • exe 単体では動かない。

実行

1062 py2exe03.jpg