0

我对试图让 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,完成。使用多达 8 个线程的 Delta 压缩。压缩对象:100% (4/4),完成。写入对象:100% (6/6),731 字节,完成。总计 6 个(增量 0),重复使用 0 个(增量 0)

4

2 回答 2

4

正如错误所说 - 您的 hello.py 代码中有一个非 ASCII 字符,但您尚未声明编码。您可以通过在声明编码的第一行或第二行中向源代码添加注释来解决此问题。例如,如果您的文件以 UTF-8 格式保存:

# coding: utf-8

有关详细信息,请参阅PEP 0263 。

于 2013-06-09T01:58:26.223 回答
-1

尝试使用 python 的 easy_install

$python easy_install Flask
于 2013-06-08T22:48:04.380 回答