python - Python:烧瓶导入失败
问题描述
我正在尝试使用 mod_wsgi 在 Apache 上部署 Flask 应用程序。我使用的是虚拟环境。但是下面的行失败了。
from flask import Flask
错误:
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] mod_wsgi (pid=6937): Target WSGI script '/var/www/sample_rest/sample_rest.wsgi' cannot be loaded as Python module.
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] mod_wsgi (pid=6937): Exception occurred processing WSGI script '/var/www/sample_rest/sample_rest.wsgi'.
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] Traceback (most recent call last):
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] File "/var/www/sample_rest/sample_rest.wsgi", line 5, in <module>
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] from sample_rest import sample_rest as application
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] File "/var/www/sample_rest/sample_rest.py", line 2, in <module>
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] from flask import Flask, request, jsonify, make_response
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] File "/var/www/sample_rest/lib/python3.6/site-packages/flask/__init__.py", line 16, in <module>
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] from werkzeug.exceptions import abort
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] File "/var/www/sample_rest/lib/python3.6/site-packages/werkzeug/__init__.py", line 15, in <module>
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] from .serving import run_simple
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] File "/var/www/sample_rest/lib/python3.6/site-packages/werkzeug/serving.py", line 51, in <module>
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] from .exceptions import InternalServerError
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] File "/var/www/sample_rest/lib/python3.6/site-packages/werkzeug/exceptions.py", line 68, in <module>
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] from .utils import escape
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] File "/var/www/sample_rest/lib/python3.6/site-packages/werkzeug/utils.py", line 189
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] "area",
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] ^
[Wed Sep 23 07:58:50 2020] [error] [client 10.192.73.242] SyntaxError: invalid syntax
如您所见,错误在烧瓶本身的代码中。我正在使用烧瓶支持的 Python-3.6.2。显示错误的烧瓶的源代码也是正确的。可能是什么问题 ?
解决方案
很抱歉发布此内容而不是评论:
尝试安装对我有用的 Flask 1.1.1:
pip install Flask==1.1.1
推荐阅读
- arcgis - 在 ArcGIS 或 QGIS 中添加大量标签是否有快速、有效的方法?
- python - How do I read a non standard csv file into dataframe with python or scala
- c - fread() 读取太多数据
- version-control - Perforce - 恢复我本地工作区中另一个用户打开的文件
- c# - 如何在不加载整个excel文件的情况下读取excel中的标题行(假设第一行是标题)
- typescript - 如何覆盖 TypeScript 中父类中重载的方法?
- ios - 如何获得 MTLTexture 内容的一致深拷贝?
- tomcat - 配置选项的 Tomcat 9 ant 部署问题。为什么?
- ios - 如何在 ViewControllers 之间为不同的 tableViews 提供相同的操作 [swift]
- javascript - Array.splice() 在数组文字上表现一种方式,在另一种方式上保存为 const