Python 导入nltk时,Flask WSGI应用程序挂起

Python 导入nltk时,Flask WSGI应用程序挂起,python,flask,wsgi,nltk,Python,Flask,Wsgi,Nltk,我按照说明创建了一个部署到apache2的onefile flask应用程序,在ubuntu上使用mod wsgi。当使用原来的flask应用程序时,所有这些都可以正常工作。但是,当向flask应用程序添加导入nltk时,apache挂起(no 500) 我使用python 2.7和nltk 2.0.4 其他软件包似乎也有类似的问题。背景 WSGIApplicationGroup %{GLOBAL} 在VirtualHost中,配置似乎有所帮助。然而,我仍然得到同样的行为。有人遇到过同样的问题

我按照说明创建了一个部署到apache2的onefile flask应用程序,在ubuntu上使用mod wsgi。当使用原来的flask应用程序时,所有这些都可以正常工作。但是,当向flask应用程序添加导入nltk时,apache挂起(no 500)

我使用python 2.7和nltk 2.0.4

其他软件包似乎也有类似的问题。背景

WSGIApplicationGroup %{GLOBAL}
在VirtualHost中,配置似乎有所帮助。然而,我仍然得到同样的行为。有人遇到过同样的问题吗?谢谢你的帮助

以下是VirtualHost配置文件:

<VirtualHost *:8080>

    # ---- Configure VirtualHost Defaults ----

    ServerAdmin jsmith@whoi.edu 

    DocumentRoot /home/bitnami/public_html/http

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /home/bitnami/public_html/http/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            Allow from all
    </Directory>

    # ---- Configure WSGI Listener(s) ----

    WSGIDaemonProcess flaskapp user=www-data group=www-data processes=1 threads=5
    WSGIScriptAlias /flasktest1 /home/bitnami/public_html/wsgi/flasktest1.wsgi 

    <Directory /home/bitnami/public_html/http/flasktest1>
            WSGIProcessGroup flaskapp
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
    </Directory>

    # ---- Configure Logging ----

ErrorLog /home/bitnami/public_html/logs/error.log
LogLevel warn
CustomLog /home/bitnami/public_html/logs/access.log combined

#----配置VirtualHost默认值----
服务器管理员jsmith@whoi.edu 
DocumentRoot/home/bitnami/public\u html/http
选项如下符号链接
不允许超限
选项索引跟随符号链接多视图
不允许超限
命令允许,拒绝
通融
#----配置WSGI侦听器----
WSGIDaemonProcess flaskapp用户=www数据组=www数据进程=1线程=5
WSGIScriptAlias/flasktest1/home/bitnami/public_html/wsgi/flasktest1.wsgi
WSGIProcessGroup烧瓶应用程序
WSGIApplicationGroup%{GLOBAL}
命令拒绝,允许
通融
#----配置日志记录----
ErrorLog/home/bitnami/public_html/logs/error.log
日志级别警告
CustomLog/home/bitnami/public_html/logs/access.log组合

这是修改后的烧瓶代码

#!/usr/bin/python
from flask import Flask

import nltk
app = Flask(__name__)
@app.route('/')
def home():
    return """<html>
    <h2>Hello from Test Application 1</h2>
    </html>"""

@app.route('/<foo>')
def foo(foo):
    return """<html>
    <h2>Test Application 1</2>
    <h3>/%s</h3>
    </html>""" % foo

if __name__ == '__main__':
    "Are we in the __main__ scope? Start test server."
    app.run(host='0.0.0.0',port=5000,debug=True)
#/usr/bin/python
从烧瓶进口烧瓶
导入nltk
app=烧瓶(名称)
@应用程序路径(“/”)
def home():
返回“”
您好,来自测试应用程序1
"""
@应用程序路径(“/”)
def foo(foo):
返回“”
测试应用程序1
/%
“”%foo
如果uuuu name uuuuuu='\uuuuuuu main\uuuuuuu':
“我们是否在主范围内?启动测试服务器。”
app.run(主机=0.0.0.0',端口=5000,调试=True)
您有:

<Directory /home/bitnami/public_html/http/flasktest1>
        WSGIProcessGroup flaskapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
</Directory>

请注意,processs=1已被删除,因为这是默认值,设置它意味着其他您可能不想要的东西。您也不需要设置user/group,因为它将自动作为Apache用户运行。

您可以发布HTTPd的error.log的相关部分吗?谢谢您的帮助!正如您所描述的,我更改了虚拟配置文件,它成功了:我删除了第二个元素,并从第三个元素中删除了/flasktest1。顺便说一句,造成冰冻的不是nltk,而是numpy和Pyaml
<Directory /home/bitnami/public_html/http>
        WSGIProcessGroup flaskapp
        WSGIApplicationGroup %{GLOBAL}
        Order deny,allow
        Allow from all
</Directory>
WSGIDaemonProcess flaskapp threads=5
WSGIScriptAlias /flasktest1 /home/bitnami/public_html/wsgi/flasktest1.wsgi process-group=flaskapp application-group=%{GLOBAL}