Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

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

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

4 Python Essential 세미나 4 ● Installer - freeze (1) ▲ 설치법 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 가 설치된다. 독립실행파일 이란 독립실행파일 생성기Installer-freeze Py2exe freeze(python) squeeze 참고사항

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

6 Python Essential 세미나 6 ● Installer - freeze (3) ▲ 사용예제 (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 독립실행파일 이란 독립실행파일 생성기Installer-freeze Py2exe freeze(python) squeeze 참고사항

7 Python Essential 세미나 7 ● Installer - freeze (4) 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 …… 독립실행파일 이란 독립실행파일 생성기Installer-freeze Py2exe freeze(python) squeeze 참고사항

8 Python Essential 세미나 8 ● Installer - freeze (5) 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 파일들이 자동으로 만들어진다. 독립실행파일 이란 독립실행파일 생성기Installer-freeze Py2exe freeze(python) squeeze 참고사항

9 Python Essential 세미나 9 ● py2exe (1) 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 이 설치하여야 한다. ▲ 설치법 독립실행파일 이란 독립실행파일 생성기 Installer-freezePy2exe freeze(python) squeeze 참고사항

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

11 Python Essential 세미나 11 ● py2exe (3) 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() 독립실행파일 이란 독립실행파일 생성기 Installer-freezePy2exe freeze(python) squeeze 참고사항

12 Python Essential 세미나 12 ● py2exe (4) 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 독립실행파일 이란 독립실행파일 생성기 Installer-freezePy2exe freeze(python) squeeze 참고사항

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

14 Python Essential 세미나 14 ● py2exe (6) ▲ 옵션 --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 에서 지원 ….. 독립실행파일 이란 독립실행파일 생성기 Installer-freezePy2exe freeze(python) squeeze 참고사항

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

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

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

18 Python Essential 세미나 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


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

Similar presentations


Ads by Google