[英]Jelastic Apache+mod_wsgi: 'module' object is not callable
I have unsuccessfully tried to install my Flask application to a Jelastic server. 我没有尝试将我的Flask应用程序安装到Jelastic服务器上。 I have there Apache 2.4 and Python 3.5.
我那里有Apache 2.4和Python 3.5。 The problem shows as a 500 Internal Server Error when I try to access my "/" page.
当我尝试访问“ /”页面时,该问题显示为500 Internal Server Error 。
[Point 1.] When restarting the Apache server, apache2-python : actions page shows some wrong values: [要点1.]重新启动Apache服务器时, apache2-python:actions页显示一些错误的值:
Starting Python 2.4 cartridge (Apache+mod_wsgi)
Application directory /opt/repo/ROOT selected as DocumentRoot
$OPENSHIFT_PYTHON_WSGI_APPLICATION=/opt/repo//ROOT/application file not found
WSGI application was not found
I think application directory should be /opt/repo/ROOT/stk_server
, which I have defined in /opt/shared/conf/etc/conf.d/openshift.conf: 我认为应用程序目录应该是
/opt/repo/ROOT/stk_server
,我在/opt/shared/conf/etc/conf.d/openshift.conf中定义了该目录:
ServerRoot "/opt/repo/"
DocumentRoot "/opt/repo/ROOT/stk-server"
WSGIScriptAlias / "/opt/repo/ROOT/stk_server.wsgi"
Why this does not apply when stating Apache? 为什么在说明Apache时这不适用? (In different manuals these paths are set in /etc/apache2/sites-available/ directory, but Jelastic environment doesn't have such.)
(在不同的手册中,这些路径是在/ etc / apache2 / sites-available /目录中设置的,但是Jelastic环境中没有这样的路径。)
[Point 2.] my /opt/shared/webroot/ROOT/stk_server.wsgi
file imports my application /opt/shared/webroot/ROOT/stk_server/hello.py
using commands [
/opt/shared/webroot/ROOT/stk_server.wsgi
2]。我的/opt/shared/webroot/ROOT/stk_server.wsgi
文件使用命令导入了我的应用程序/opt/shared/webroot/ROOT/stk_server/hello.py
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/opt/repo/ROOT/stk_server")
import os
os.chdir("/opt/repo/ROOT/stk_server")
from stk_server import hello as application
The hello.py
is like this: hello.py
是这样的:
from flask import Flask
app = Flask(__name__)
print("Running my hello.py={}.".format(__name__))
print("My app={}.".format(app))
@app.route("/")
def hello():
return "Hello, I love Python!"
if __name__ == "__main__":
print ("Starting my hello.__main__")
app.run()
The error_log
shows these wsgi:errors: error_log
显示以下wsgi:errors:
Running my hello.py=stk_server.hello.
My app=<Flask 'stk_server.hello'>.
[remote 10...:228] mod_wsgi (pid=27564): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'.
[remote 10...:228] TypeError: 'module' object is not callable
[remote 10...:236] mod_wsgi (pid=27565): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'.
[remote 10...:236] TypeError: 'module' object is not callable
[remote 10...:228] mod_wsgi (pid=27564): Exception occurred processing WSGI script '/opt/repo/ROOT/stk_server.wsgi'.
[remote 10...:228] TypeError: 'module' object is not callable
What is this 'module' object? 这个“模块”对象是什么? The same error occurs, when the project directory
/opt/shared/webroot/ROOT/stk_server
has a __init__.py
file or not. 当项目目录
/opt/shared/webroot/ROOT/stk_server
是否具有__init__.py
文件时,也会发生相同的错误。
We have checked your environment and found incorrect imported "app" in the stk_server.wsgi file. 我们已经检查了您的环境,并在stk_server.wsgi文件中找到了错误导入的“ app”。 The right way:
正确的方式:
from stk_server.hello import app as application
Have a nice day, Jelastic Support! 祝您有美好的一天,Jelastic支持!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.