处理 WSGI 脚本 SyntaxError from item-catalog import app as application 发生异常
Exception occurred processing WSGI script SyntaxError from item-catalog import app as application
我在尝试使用 Apache 设置我的 python 项目后收到内部服务器错误。这行 SyntaxError:
有问题
from item-catalog import app as application
但是如果我改成这样,也不行。
import app as application
工作。我的文件夹结构是
/var/www/html/itemcatalog/item-catalog
这是我的 itemcatalog.wsgi 文件
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/html/itemcatalog")
from item-catalog import app as application
application.secret_key = 'kGTdasfdasfdsa'
这是 apache 错误日志:
[Tue Dec 13 02:12:09.149063 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] mod_wsgi (pid=29155): Exception occurred processing WSGI script '/var/www/html/itemcatalog/item-catalog/itemcatalog.wsgi'.
[Tue Dec 13 02:12:09.149155 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] File "/var/www/html/itemcatalog/item-catalog/itemcatalog.wsgi", line 7
[Tue Dec 13 02:12:09.149202 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] from item-catalog import app as application
[Tue Dec 13 02:12:09.149244 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] ^
[Tue Dec 13 02:12:09.149283 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] SyntaxError: invalid syntax
Python 模块名称中不能包含连字符
我在尝试使用 Apache 设置我的 python 项目后收到内部服务器错误。这行 SyntaxError:
有问题from item-catalog import app as application
但是如果我改成这样,也不行。
import app as application
工作。我的文件夹结构是
/var/www/html/itemcatalog/item-catalog
这是我的 itemcatalog.wsgi 文件
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/html/itemcatalog")
from item-catalog import app as application
application.secret_key = 'kGTdasfdasfdsa'
这是 apache 错误日志:
[Tue Dec 13 02:12:09.149063 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] mod_wsgi (pid=29155): Exception occurred processing WSGI script '/var/www/html/itemcatalog/item-catalog/itemcatalog.wsgi'.
[Tue Dec 13 02:12:09.149155 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] File "/var/www/html/itemcatalog/item-catalog/itemcatalog.wsgi", line 7
[Tue Dec 13 02:12:09.149202 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] from item-catalog import app as application
[Tue Dec 13 02:12:09.149244 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] ^
[Tue Dec 13 02:12:09.149283 2016] [:error] [pid 29155:tid 139672369694464] [client 108.49.103.204:53087] SyntaxError: invalid syntax
Python 模块名称中不能包含连字符