总是觉的学习东西有点猴子掰玉米的感觉。今天就重新再掰一次吧。
Installation:
安装之前建议先安装virtualenv,这个东东是帮助你在多个python版本之间保持同步,不至于python版本变化了,项目就奔溃了。
某些程序猿的装备好些,可能用的是mac,自有类linux的安装方法。无奈本屌丝只能在win下来写写程序。所以只提供win的virtualenv安装方法:
到这里下载http://flask.pocoo.org/docs/installation/#windows-easy-install, 创建python 文件,拷贝 distribute_setup.py的内容。然后双击即可。
也可参考这篇文章,非常详细:http://f.dataguru.cn/thread-36396-1-1.html
1. 安装pip : easy_install.py pip
2. 安装virtualenv: easy_install.py virtualenv
安装完成记得在环境变量里面添加路径。
APP:
现在新创建一个文件夹,给这个文件夹设置python环境。
F:>cd flask F:flask>cd picshow F:flaskpicshow>virtualenv env New python executable in envScriptspython.exe Installing Setuptools........................................................... ................................................................................ ................................................................................ .......................done. Installing Pip.................................................................. ................................................................................ ................................................................................ ................................................................................ .....................done. F:flaskpicshow>
接下来激活这个环境
envScriptsactivate
最后,为应用添加Flask:
F:flaskpicshow>envScriptsactivate (env) F:flaskpicshow>pip install Flask Downloading/unpacking Flask Downloading Flask-0.10.1.tar.gz (544kB): 544kB downloaded Running setup.py egg_info for package Flask 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' Downloading/unpacking Werkzeug>=0.7 (from Flask) Downloading Werkzeug-0.9.4.tar.gz (1.1MB): 1.1MB downloaded Running setup.py egg_info for package Werkzeug warning: no files found matching '*' under directory 'werkzeugdebug emplat es' 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' Downloading/unpacking Jinja2>=2.4 (from Flask) Downloading Jinja2-2.7.1.tar.gz (377kB): 377kB downloaded Running setup.py egg_info for package Jinja2 warning: no files found matching '*' under directory 'custom_fixers' warning: no previously-included files matching '*' found under directory 'do cs\_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' Downloading/unpacking itsdangerous>=0.21 (from Flask) Downloading itsdangerous-0.23.tar.gz (46kB): 46kB downloaded Running setup.py egg_info for package itsdangerous warning: no previously-included files matching '*' found under directory 'do cs\_build' Downloading/unpacking markupsafe (from Jinja2>=2.4->Flask) Downloading MarkupSafe-0.18.tar.gz Running setup.py egg_info for package markupsafe Installing collected packages: Flask, Werkzeug, Jinja2, itsdangerous, markupsafe Running setup.py install for Flask 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' Running setup.py install for Werkzeug warning: no files found matching '*' under directory 'werkzeugdebug emplat es' 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' Running setup.py install for Jinja2 warning: no files found matching '*' under directory 'custom_fixers' warning: no previously-included files matching '*' found under directory 'do cs\_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' Running setup.py install for itsdangerous warning: no previously-included files matching '*' found under directory 'do cs\_build' Running setup.py install for markupsafe building 'markupsafe._speedups' extension ========================================================================== 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. ========================================================================== Successfully installed Flask Werkzeug Jinja2 itsdangerous markupsafe Cleaning up... (env) F:flaskpicshow>