1 / 18

Python Essential 세미나

Python Essential 세미나. 2001. 4. 24( 화 ). Windows 에서 독립실행파일 만들기. 발표자 : 김진열. ● 독립실행파일이란 ?. 독립실행파일 이란 ? 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항. Python 프로그램이 설치되지 않은 컴퓨터에서 Python script 를 실행할 수 있는 파일 즉 , 이 파일은 Python 의 script 해석기와 Import 된 Module 들을

fynn
Télécharger la présentation

Python Essential 세미나

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Python Essential 세미나 2001. 4. 24(화) Windows에서 독립실행파일 만들기 발표자 : 김진열

  2. ●독립실행파일이란? 독립실행파일 이란? 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 Python 프로그램이 설치되지 않은 컴퓨터에서 Python script를 실행할 수 있는 파일 즉, 이 파일은 Python의 script 해석기와 Import된 Module들을 포함한다.

  3. ●독립실행파일 생성기 독립실행파일 이란? 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 독립실행파일 생성기란 독립파일을 생성하기 위해 Python script 해석기와 Import된 Module들을 묶어주는 프로그램이다. 대표적인 프로그램으로는 installer-freeze, py2exe, freeze, squeeze 등이 있다.

  4. ● Installer - freeze (1) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 설치법 1. http://starship.python.net/crew/gmcm/installer_dnld.html에서 installer를 다운로드 받는다.(최근버젼 : Beta 3f) 2. Install파일(Installer_b_03f.exe)를 실행하면 인스톨할 경로 를 물어본다. Enter an installation directory : 3. 가급적이면 Python이 설치된 곳에 새로 만든다. (가끔 실행하는 디렉토리와 설치되는 디렉토리가 같으면 에러가 발생한다.) 4. 설정한 디렉토리에 Installer가 설치된다.

  5. ● Installer - freeze (2) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 사용방법 1. 확장 Module을 사용하지 않은 소스의 독립실행파일 만들 경우 Prompt>python {freeze-path}/freeze.py 소스파일 2. 확장 Module을 사용할 경우 freeze.py 파일중 ‘include=’ 다음에 포함될 DLL파일을 넣어주고 그 DLL파일을 windows 디렉토리에 복사한후 1번 사용법처럼 실행시켜주면 된다. [MYZLIB] type=PYZ …… include= “”” ……

  6. ● Installer - freeze (3) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 사용예제 (Tkinter를 이용한 간단한 프로그램) 1. 소스 : hello_python.py # hello_python.py from Tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() root.mainloop() 2. 우선 필요한 DLL파일이 무엇인지 알아보기 위해 freeze를 실행한다. Python c:\python15\tools\freeze\freeze.py hello_python.py

  7. ● Installer - freeze (4) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 3. Freeze가 실행되면서 다음과 같은 문구를 볼 수 있다. …. lib not found: tcl80.dll dependency of found tk80.dll lib not found: tk80.dll dependency of found python15.dll …. 4. tcl80.dll과 tk80.dll를 찾아서 windows 디렉토리에 복사하고 freeze.py 파일내의 include 부분을 수정한다. [MYZLIB] type=PYZ …… include= C:\\Program Files\\Tcl\\bin\\tcl80.dll, C:\\Program Files\\Tcl\\bin\\tk80.dll ……

  8. ● Installer - freeze (5) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 5. 다시 freeze를 실행한다. Python c:\python15\tools\freeze\freeze.py hello_python.py 그러면 lib not found된 것이 analyzing 된 것을 알 수 있다. …. analyzing tcl80.dll …. analyzing tk80.dll …. 6. hello_python.exe가 생성되었음을 알 수 있다. 이것을 실행하면 필요한 .dll, .pyd 파일들이 자동으로 만들어진다.

  9. ● py2exe (1) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 설치법 1. http://starship.python.net/crew/theller/py2exe/에서 py2exe를 다운로드 받는다.(최근버젼 : 0.2.5) 2. Python 1.6 이상 버전일 경우 Install파일을 실행하면 설치완료 3. Python 1.6 아래 버전일 경우 Distutils가 설치되어 있어야 하며 Install파일을 실행하여 설치한 후 zip.exe 파일과 zipfile module이 설치하여야 한다.

  10. ● py2exe (2) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 사용방법 1. 우선 setup.py 파일을 만든다. #setup.py from distutils.core import setup import py2exe setup(name=“프로그램 작업명”, script=[“독립실행파일을 만들려는 소스파일”], ) 2. Py2exe를 실행시킨다. Prompt> Python setup.py py2exe

  11. ● py2exe (3) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 3. 실행시킨 디렉토리 위치에서 Dist란 디렉토리가 생기고 그 하위 디렉토리에 소스파일의 파일명과 같은 디렉토리가 생성이 된다. 그 디렉토리에는 독립실행파일과 실행에 필요한 각종 파일들이 함께 만들어 진다. ▲ 사용예제(Tkinter를 이용한 간단한 프로그램) 1. 소스 : hello_python.pyw # hello_python.pyw from Tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() root.mainloop()

  12. ● py2exe (4) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 2. setup.py 파일 #setup.py from distutils.core import setup import py2exe setup(name=“Hello Python”, script=[“hello_python.pyw”], ) 3. 독립실행파일 작성 C:\Test> Python setup.py py2exe

  13. ● py2exe (5) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 4. 실행결과

  14. ● py2exe (6) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 옵션 --debug or -g : 디버그 정보를 runtime동안 생성한다. --optimize or -O0/1/2 : optimize --dist-dir or -d directory : 실행파일이 생성되는곳 정의 --force or -f : 모든것을 강제로 다시 생성 --keep-temp or -k : 실행파일이 생성될때 임시적으로 만들어지는 파일들을 남긴다. (일반적으로 독립실행파일이 만들어지면 이 파일들은 지워진다.) --console or -c : 도스용 모드일때 (.py) 사용 --windows or -w : 윈도우용 모드일때 (.pyw) 사용 --exclude or -e list : exclude할 module로 콤마(,) 로 구분된다. --incldue or -I list : include할 module로 콤마(,) 로 구분된다. --icon ico-file : icon파일을 정의, windowsNT 또는 windows2000에서 지원 …..

  15. ● freeze 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 Python의 tools 디렉토리의 freeze 디렉토리를 보면 freeze.py 를 볼 수있는데 이 모듈을 사용하면 c파일로 만들어 지게 되며 이것을 컴파일하여 파이선이 내장된 프로그램을 만들 수 있다. ● squeeze Py2exe와 유사한 것으로 현재 python 1.4 버전용이 있다.

  16. Installer-freeze py2exe Python1.5.2 파일생성/실행실패 파일생성/실행실패 Python20 파일생성 X /실행실패 파일생성/실행성공 ● 참고사항 (1) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 독립실행파일 생성기 사용후기 현재 나와있는 installer-freeze는 python1.5.2 버전에서만 독립 실행파일이 생성되었다. 그러나 외부모듈을 Import하여 사용 했을시(Tkinter) 독립파일생성은 이루어 졌으나 실제로 파이선 이 없는 컴퓨터에서 실행했을때 실행을 하지 않았다. 그리고 py2exe는 python1.5.2 버전, python2.0 버전에서 독립 실행파일이 생성되었지만 외부모듈(Tkinter)을 Import하여 사용했을 시 python1.5.2 버전에서는 실제로 파이선이 없는 컴퓨터에서 실행했을 때 실행되지는 않았다. 그러나 python2.0 에서 만들어진 독립파일은 실행되었다. Tkinter를 이용한 독립실행파일 생성여부

  17. Python1.5.2 BeOpen- Python20 Active- Python20 Win32all X X O Distutils X O O Tcl/TK O (ver.8.0) O (ver.8.3) X ● 참고사항 (2) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ Windows 기반 Python 기본 개발환경 Python program : Python 기본 프로그램 Win32all :윈도우즈 플랫폼에 관련된 파이썬 모듈 Distutils :파이선 모듈을 설치해주는 프로그램 Tcl/TK : Tcl/TK 스크립트 언어 ※ 패키지별 구성

  18. ● 참고사항 (2) 독립실행파일 이란 독립실행파일 생성기 Installer-freeze Py2exe freeze(python) squeeze 참고사항 ▲ 참고 사이트 Installer : http://starship.python.net/crew/gmcm/install.html py2exe : http://starship.python.net/crew/theller/py2exe/ squeeze : http://www.pythonware.com/products/python/squeeze/index.htm

More Related