참고 : http://flask.pocoo.org/docs/installation/
1. Flask 개발을 위한 환경 설정
Flask는 Werkzeug 와 Jinja2 라이브러리에 의존적
Werkzeug는 웹어플리케이션과 다양한 서버 사이의 개발과 배포를 위한 표준 파이썬 인터페이스인 WSGI를 구현한 툴킷
Jinja2 는 HTML 템플릿을 렌더링 하는 템플릿 엔진
1.1. python 설치
Python 2.5 또는 상위 버전을 사용(파이썬 3.x 버전을 지원안됨, 0.10 이상에선 지원된다는 이야기도..)
1.2 easy_install, pip 설치
생략 – http://apollo89.com/wordpress/?p=3627 참고
1.3 virtualenv 설치
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
C:\Python27>pip install virtualenv Downloading/unpacking virtualenv Downloading virtualenv-1.10.1.tar.gz (1.3MB): 1.3MB downloaded Running setup.py egg_info for package virtualenv warning: no files found matching '*.egg' under directory 'virtualenv_support' warning: no previously-included files matching '*' found under directory 'docs\_templates' warning: no previously-included files matching '*' found under directory 'docs\_build' Installing collected packages: virtualenv Running setup.py install for virtualenv warning: no files found matching '*.egg' under directory 'virtualenv_support' warning: no previously-included files matching '*' found under directory 'docs\_templates' warning: no previously-included files matching '*' found under directory 'docs\_build' Installing virtualenv-script.py script to C:\Python27\Scripts Installing virtualenv.exe script to C:\Python27\Scripts Installing virtualenv.exe.manifest script to C:\Python27\Scripts Installing virtualenv-2.7-script.py script to C:\Python27\Scripts Installing virtualenv-2.7.exe script to C:\Python27\Scripts Installing virtualenv-2.7.exe.manifest script to C:\Python27\Scripts Successfully installed virtualenv Cleaning up... C:\Python27>mkdir flask_pjt C:\Python27>cd flask_pjt C:\Python27\flask_pjt>virtualenv venv New python executable in venv\Scripts\python.exe Installing Setuptools............................................................................... .................................................................................................... .................................................................done. Installing Pip...................................................................................... .................................................................................................... .................................................................................................... ...........................................done. C:\Python27\flask_pjt>tree 로컬 디스크 볼륨에 대한 폴더 경로의 목록입니다. 볼륨 일련 번호는 00XX-XXXX입니다. . └─venv ├─Include ├─Lib │ ├─distutils │ ├─encodings │ └─site-packages │ ├─pip │ │ ├─backwardcompat │ │ ├─commands │ │ ├─vcs │ │ └─vendor │ │ ├─distlib │ │ │ └─_backport │ │ └─html5lib │ │ ├─filters │ │ ├─serializer │ │ ├─treebuilders │ │ ├─treewalkers │ │ └─trie │ ├─pip-1.4.1-py2.7.egg-info │ ├─setuptools │ │ ├─command │ │ ├─tests │ │ └─_backport │ │ └─hashlib │ ├─setuptools-0.9.8-py2.7.egg-info │ └─_markerlib └─Scripts C:\Python27\flask_pjt>venv\scripts\activate (venv) C:\Python27\flask_pjt> |
1.4 Flask 설치
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
(venv) C:\Python27\flask_pjt>pip install Flask Downloading/unpacking Flask Could not fetch URL https://pypi.python.org/simple/Flask/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIF ICATE:certificate verify failed> Will skip URL https://pypi.python.org/simple/Flask/ when looking for download links for Flask Could not fetch URL https://pypi.python.org/simple/: There was a problem confirming the ssl certif icate: <urlopen error [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE: certificate verify failed> Will skip URL https://pypi.python.org/simple/ when looking for download links for Flask Cannot fetch index base URL https://pypi.python.org/simple/ Could not fetch URL https://pypi.python.org/simple/Flask/: There was a problem confirming the ssl certificate: <urlopen error [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIF ICATE:certificate verify failed> Will skip URL https://pypi.python.org/simple/Flask/ when looking for download links for Flask Could not find any downloads that satisfy the requirement Flask Cleaning up... No distributions at all found for Flask Storing complete log in C:\Users\apollo89\pip\pip.log (venv) C:\Python27\flask_pjt> |
에러발생..
구글로 검색해서 해결하려고 시도했지만 안됨..
그래서 그냥 flask 를 받아서 설치하기로 결정
https://github.com/mitsuhiko/flask 에서 zip 파일 다운로드 후 압축을 풀고 설치
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
(venv) C:\Python27\flask_pjt\flask>python setup.py develop running develop running egg_info creating Flask.egg-info writing requirements to Flask.egg-info\requires.txt writing Flask.egg-info\PKG-INFO writing top-level names to Flask.egg-info\top_level.txt writing dependency_links to Flask.egg-info\dependency_links.txt writing manifest file 'Flask.egg-info\SOURCES.txt' reading manifest file 'Flask.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching '*' under directory 'tests' warning: no previously-included files matching '*.pyc' found under directory 'docs' warning: no previously-included files matching '*.pyo' found under directory 'docs' warning: no previously-included files matching '*.pyc' found under directory 'tests' warning: no previously-included files matching '*.pyo' found under directory 'tests' warning: no previously-included files matching '*.pyc' found under directory 'examples' warning: no previously-included files matching '*.pyo' found under directory 'examples' no previously-included directories found matching 'docs\_build' no previously-included directories found matching 'docs\_themes\.git' writing manifest file 'Flask.egg-info\SOURCES.txt' running build_ext Creating c:\python27\flask_pjt\flask\venv\lib\site-packages\Flask.egg-link (link to . ) Adding Flask 0.11-dev-20130912 to easy-install.pth file Installed c:\python27\flask_pjt\flask Processing dependencies for Flask==0.11-dev-20130912 Searching for itsdangerous>=0.21 Reading https://pypi.python.org/simple/itsdangerous/ Best match: itsdangerous 0.23 Downloading https://pypi.python.org/packages/source/i/itsdangerous/itsdangerous-0.23.tar.gz#md5=985e 726eb76f18aca81e703f0a6c6efc Processing itsdangerous-0.23.tar.gz Writing c:\users\apollo89\appdata\local\temp\easy_install-56pclg\itsdangerous-0.23\setup.cfg Running itsdangerous-0.23\setup.py -q bdist_egg --dist-dir c:\users\apollo89\appdata\local\temp\easy_ins tall-56pclg\itsdangerous-0.23\egg-dist-tmp-3wt_xw warning: no previously-included files matching '*' found under directory 'docs\_build' Adding itsdangerous 0.23 to easy-install.pth file Installed c:\python27\flask_pjt\flask\venv\lib\site-packages\itsdangerous-0.23-py2.7. egg Searching for Jinja2>=2.4 Reading https://pypi.python.org/simple/Jinja2/ Best match: Jinja2 2.7.1 Downloading https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.1.tar.gz#md5=282aed153e69f97 0d6e76f78ed9d027a Processing Jinja2-2.7.1.tar.gz Writing c:\users\apollo89\appdata\local\temp\easy_install-suszs0\Jinja2-2.7.1\setup.cfg Running Jinja2-2.7.1\setup.py -q bdist_egg --dist-dir c:\users\apollo89\appdata\local\temp\easy_install- suszs0\Jinja2-2.7.1\egg-dist-tmp-0imm4r warning: no files found matching '*' under directory 'custom_fixers' warning: no previously-included files matching '*' found under directory 'docs\_build' warning: no previously-included files matching '*.pyc' found under directory 'jinja2' warning: no previously-included files matching '*.pyc' found under directory 'docs' warning: no previously-included files matching '*.pyo' found under directory 'jinja2' warning: no previously-included files matching '*.pyo' found under directory 'docs' Adding jinja2 2.7.1 to easy-install.pth file Installed c:\python27\flask_pjt\flask\venv\lib\site-packages\jinja2-2.7.1-py2.7.egg Searching for Werkzeug>=0.7 Reading https://pypi.python.org/simple/Werkzeug/ Best match: Werkzeug 0.9.4 Downloading https://pypi.python.org/packages/source/W/Werkzeug/Werkzeug-0.9.4.tar.gz#md5=670fad41f57 c13b71a6816765765a3dd Processing Werkzeug-0.9.4.tar.gz Writing c:\users\apollo89\appdata\local\temp\easy_install-iqvjzl\Werkzeug-0.9.4\setup.cfg Running Werkzeug-0.9.4\setup.py -q bdist_egg --dist-dir c:\users\apollo89\appdata\local\temp\easy_instal l-iqvjzl\Werkzeug-0.9.4\egg-dist-tmp-jhxeek warning: no files found matching '*' under directory 'werkzeug\debug\templates' warning: no files found matching '*' under directory 'tests' warning: no previously-included files matching '*.pyc' found under directory 'docs' warning: no previously-included files matching '*.pyo' found under directory 'docs' warning: no previously-included files matching '*.pyc' found under directory 'tests' warning: no previously-included files matching '*.pyo' found under directory 'tests' warning: no previously-included files matching '*.pyc' found under directory 'examples' warning: no previously-included files matching '*.pyo' found under directory 'examples' no previously-included directories found matching 'docs\_build' Adding werkzeug 0.9.4 to easy-install.pth file Installed c:\python27\flask_pjt\flask\venv\lib\site-packages\werkzeug-0.9.4-py2.7.egg Searching for markupsafe Reading https://pypi.python.org/simple/markupsafe/ Best match: MarkupSafe 0.18 Downloading https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.18.tar.gz#md5=f8d252fd 05371e51dec2fe9a36890687 Processing MarkupSafe-0.18.tar.gz Writing c:\users\apollo89\appdata\local\temp\easy_install-cgvbgt\MarkupSafe-0.18\setup.cfg Running MarkupSafe-0.18\setup.py -q bdist_egg --dist-dir c:\users\apollo89\appdata\local\temp\easy_insta ll-cgvbgt\MarkupSafe-0.18\egg-dist-tmp-dexh4x ========================================================================== WARNING: The C extension could not be compiled, speedups are not enabled. Failure information, if any, is above. Retrying the build without the C extension now. ========================================================================== WARNING: The C extension could not be compiled, speedups are not enabled. Plain-Python installation succeeded. ========================================================================== Adding markupsafe 0.18 to easy-install.pth file Installed c:\python27\flask_pjt\flask\venv\lib\site-packages\markupsafe-0.18-py2.7.eg g Finished processing dependencies for Flask==0.11-dev-20130912 (venv) C:\Python27\flask_pjt\flask> |
설치완료!(몇몇 WARNING이 있지만 크게 문제되것 같지 않아 Pass~)
정상적으로 동작하는지 확인을 위해 hello 프로그램 작성
1 2 3 4 5 6 7 8 9 |
from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return 'Hello Apollo89!' if __name__ == '__main__': app.run() |
실행결과
1 2 3 |
(venv) C:\Python27\flask_pjt>python hello.py * Running on http://127.0.0.1:5000/ 127.0.0.1 - - [12/Sep/2013 23:08:03] "GET / HTTP/1.1" 200 - |
정상접속!!
One Response to Flask 설치하기