从item-catalog import app处理WSGI脚本SyntaxError作为应用程序发生异常

时间:2016-12-13 02:17:55

标签: python apache wsgi

尝试使用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

1 个答案:

答案 0 :(得分:2)

Python模块名称中不能包含连字符