当前位置: 首页 > 知识库问答 >
问题:

烧瓶应用程序不工作

房学文
2023-03-14

在过去的几周里,我花了太多的时间试图让它发挥作用。我的目标是使用烧瓶框架创建一个简单的网络应用程序,但我不断收到错误,几个小时的谷歌搜索和搜索stackoverflow也没有帮助。

我正在学习一个教程,该教程要求我运行:$python3 routes.py

只有我才能得到以下错误:

回溯(最近的最后一次调用):文件“routes.py”,第1行,从flask导入flask中,呈现\u模板导入错误:没有名为“flask”的模块

好的那么烧瓶没有安装?显然,每个网站都告诉我输入$pip安装烧瓶

警告:在目录“tests”下找不到与“”匹配的文件警告:在目录“docs”下找不到以前包含的文件。pyc警告:在目录“docs”下找不到以前包含的文件。pyo警告:在目录“tests”下找不到以前包含的文件。pyc警告:没有以前包含的文件在目录“tests”下找到了匹配的“.pyo”警告:在目录“examples”下找不到与“.pyc”匹配的以前包含的文件

…雅达雅达雅达。。。

错误:无法创建/库/Python/2.7/site-包/烧瓶:拒绝权限

有人愿意牵着我的手度过难关吗?我应该怎么做才能让事情运转起来?

Joshua:~Joshua$sudo pip install flask Downloading/unpacking flask Downloading flask-0.10.1.tar.gz(544kB):544kB下载运行setup.py(路径:/private/tmp/pip_build_root/flask/setup.py)包flask的egg_信息

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'

下载/解包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'

下载/解包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'

下载/解包

warning: no previously-included files matching '*' found under directory 'docs/_build'

下载/解压标记安全(从Jinja2

安装收集的软件包:烧瓶,Werkzeug,Jinja2,它的危险,标记安全运行setup.py安装烧瓶

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'

运行setup.py安装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'

运行setup.py安装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'

正在运行setup.py安装以获取其信息

warning: no previously-included files matching '*' found under directory 'docs/_build'

运行setup.py安装

building 'markupsafe._speedups' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c markupsafe/_speedups.c -o build/temp.macosx-10.9-intel-2.7/markupsafe/_speedups.o
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
==========================================================================
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.
==========================================================================

成功安装烧瓶Werkzeug Jinja2其危险标记安全清理。。。

共有2个答案

谷梁英资
2023-03-14

如果你想使用Python3,你必须为Python3安装flask——你目前只在2.7上安装它。

将-3.0替换为系统上实际安装的版本。

替代:Python3 /usr/bin/pip安装Flask(pip可能安装在其他地方?)

pip:处理多个Python版本?

如何为特定版本的安装模块使用pip?

佘缪文
2023-03-14

好吧,首先。烧瓶没有安装,所以我们必须先安装它。

在UNIX中安装stuff(在您的情况下是Mac)时,需要root权限。有很多方法可以将东西作为根运行,最简单的是

sudo YOUR COMMAND HERE

所以如果你想安装烧瓶,你会运行:

sudo pip install flask

然后,打开一个python shell并导入烧瓶,它应该工作正常。

 My-MacBook-Pro:~ user$ python
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import flask
>>>

顺便说一句,Enthow Canopy是一个免费的python环境,可以满足您的大部分python需求,包括帮助您安装软件包。如果这不起作用,请让我知道:)

 类似资料:
  • 我试图在python中构建一个可以从XAMPP的Apache运行的应用程序,因此我安装了flask(),并按照以下说明进行mod_wsgi安装http://modwsgi.readthedocs.io/en/develop/user-guides/quick-installation-guide.html.我使用XAMPP的Apache,版本2.4.29和anaconda的python 3.6.4

  • 我试图将来自一个非常简单的flask应用程序的应用程序日志消息保存在日志文件中。当我使用嵌入式Flask服务器运行应用程序时,这项功能完美无瑕,但在gUnicorn中运行时,它根本不起作用,基本上,运行gUnicorn时,不会将任何应用程序输出重定向到日志文件(我的Flask应用程序中指定的日志文件)或标准输出。 也就是说,这是我的烧瓶应用程序: 现在,如果我以以下方式启动应用程序: 我得到预期的

  • 我希望能够运行我的破折号应用程序从我的烧瓶应用程序,当我去一个特定的网址/破折号。然而,我得到以下错误。TypeError:视图函数没有返回有效的响应。该函数要么返回无,要么结束时没有返回语句。' flaskapp.py dashapp。派克 如果我对我的flaskapp.py做以下更改, 我得到了以下错误,AttributeError:“非类型”对象没有属性“遍历”

  • 我正在开发一个用python运行的应用程序(始终是热泵系统的控制器),我使用flask提供一个用户界面来控制应用程序。 烧瓶应用程序有不同的控制项,例如打开或关闭系统的按钮。 我试图从python模块执行一个特定的功能,以响应按钮上的“单击”(最终目标是更改mmap资源中的一个值,该值将在另一个模块中读取以更改系统的状态)。 在flask应用程序中,我有如下内容: 但是,这会产生“内部服务器错误”

  • 我的GAE项目有以下目录结构: 我在insights.py文件中的import语句之前添加了以下代码: 问题是,现在我可以正确地导入第三个库,但我的无法工作。 我发送一个post请求,它返回状态200,但它不在我的@app.route代码中,我实际上可以发送任何路由,它只是返回200,但不是数据和错误。 对此有什么建议吗?提前感谢!

  • 在CentOS 6.4中,我在/var/www/html/venv文件夹中创建了python虚拟环境。然后在激活虚拟环境后,我为我的flask应用程序安装了所有必要的python库。我检查了一下,Flask库位于/var/www/html/venv/lib/python2.7/site-packages文件夹中。我已经安装并加载了mod_wsgi。现在,在我的flask应用程序中(位于/var/w