简体   繁体   English

Jelastic Apache + mod_wsgi:“模块”对象不可调用

[英]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.

相关问题 apache + mod_wsgi下的cx_Oracle 5.1.1 - cx_Oracle 5.1.1 under apache+mod_wsgi Django apache + mod_wsgi openPanel virtualenv设置 - Django apache+mod_wsgi openPanel virtualenv setup Ubuntu-Python-Apache2-Mod_WSGI-Django:没有名为/ TypeError / TemplateSyntaxError /&#39;str&#39;对象的模块不可调用 - Ubuntu - Python - Apache2 - Mod_WSGI - Django: No module named / TypeError / TemplateSyntaxError / 'str' object is not callable 我需要怎么做才能使apache + mod_wsgi的django工作? 我不断收到设置模块的导入错误 - What do I need to do to make django work using apache+mod_wsgi? I keep getting an import error for the settings module 在apache + mod_wsgi下运行subprocess.Popen总是返回一个错误,返回码为-6 - running subprocess.Popen under apache+mod_wsgi is always returning an error with a returncode of -6 具有apache + mod_wsgi(带有ubuntu的Amazon EC2服务器)的单个域上的Django-CMS和LFS - Django-CMS and LFS on single domain with apache+mod_wsgi (amazon ec2 server with ubuntu) 将模块加载到apache + mod-wsgi中 - Load module into apache + mod-wsgi django + mod_wsgi + apache上的初始化模块 - initializing module on django+mod_wsgi+apache 流浪汉,WSGI,virtualenv和TypeError:“模块”对象不可调用 - Vagrant, WSGI, virtualenv and TypeError: 'module' object is not callable Apache 和 mod_wsgi - Apache and mod_wsgi
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM