我对尝试让Flask运行感到非常沮丧。我尝试过安装多种方式,但无论如何,我都会遇到一些问题,而不知道如何或为什么。
下面是一个搞乱的示例。这是我的参考:http://flask.pocoo.org/docs/quickstart/
Shahs-MacBook-Pro:newpython ssaullah$ . venv/bin/activate
(venv)Shahs-MacBook-Pro:newpython ssaullah$ pip install Flask
Downloading/unpacking Flask
Downloading Flask-0.9.tar.gz (481kB): 481kB 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.8.3.tar.gz (1.1MB): 1.1MB downloaded
Running setup.py egg_info for package Werkzeug
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'
Downloading/unpacking Jinja2>=2.4 (from Flask)
Downloading Jinja2-2.7.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 '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'
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, 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 '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'
Running setup.py install for Jinja2
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'
Running setup.py install for markupsafe
building 'markupsafe._speedups' extension
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -g -O2 -DNDEBUG -g -O3 -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c markupsafe/_speedups.c -o build/temp.macosx-10.3-fat-2.7/markupsafe/_speedups.o
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -g build/temp.macosx-10.3-fat- 2.7/markupsafe/_speedups.o -o build/lib.macosx-10.3-fat-2.7/markupsafe/_speedups.so
成功安装Flask Werkzeug Jinja2 markupsafe 清理......
-
(venv)Shahs-MacBook-Pro:newpython ssaullah$ touch hello.py
(venv)Shahs-MacBook-Pro:newpython ssaullah$ open hello.py
(venv)Shahs-MacBook-Pro:newpython ssaullah$ python hello.py
File "hello.py", line 4
SyntaxError: Non-ASCII character '\xe2' in file hello.py on line 4, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
(venv)Shahs-MacBook-Pro:newpython ssaullah$
Shahs-MacBook-Pro:helloflask ssaullah $ git push heroku master 计数对象:6,完成。 Delta压缩使用多达8个线程。 压缩对象:100%(4/4),完成。 写入对象:100%(6/6),731字节,完成。 总计6(delta 0),重用0(delta 0)
答案 0 :(得分:4)
正如错误所说 - 你的hello.py代码中有一个非ASCII字符,但你还没有声明编码。您可以通过在声明编码的第一行或第二行中为源代码添加注释来解决此问题。例如,如果您的文件以UTF-8保存:
# coding: utf-8
有关详细信息,请参阅PEP 0263。
答案 1 :(得分:-1)
尝试使用python的easy_install
$python easy_install Flask