在 wsgi 中导入 python 模块时出现 500 内部服务器错误 [英] 500 internal server error when importing a python module in wsgi

查看:43
本文介绍了在 wsgi 中导入 python 模块时出现 500 内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Python 脚本,它使用 PEST wsgi 库异步执行函数.但是,当我尝试导入另一个模块时,它只会导致 500 错误.

I've got a Python script that is executing functions asynchronously by using PEST wsgi library. However, when I try to import another module it simply results in a 500 error.

我尝试引用它的方式是:

The way I try to reference it is:

from foo import * 
from foo import Foo

其中 foo 是一个文件 .py,我在其中拥有要引用的对象.

where foo is a file .py in which I have the object that I want to reference to.

尝试通过 Chrome 的 Inspect Element Control 监控调用,但找不到任何东西.

Tried to monitor the calls through Chrome's Inspect Element Control but couldn't find a thing.

还尝试使用 Apache 的错误日志进行调试,但没有任何结果.
任何提示表示赞赏.

Also tried to debug using Apache's error log, but nothing there.
Any hints appreciated.

更新:我尝试了以下导致相同 500 错误的方法:

Update: I've tried the following which resulted in the same 500 error:

--利用

import site 

site.addsitedir("path/to/my/py/files/folder")

--通过插入以下内容来修改 Apache2 httpd.conf 文件:

--modify the Apache2 httpd.conf file by inserting the following:

WSGIPythonPath /path/to/my/py/files/folder

--修改/etc/apache2/sites-available/myapp.conf中的应用conf文件,插入上面的WSGIPythonPath

--modify the application conf file in /etc/apache2/sites-available/myapp.conf, by inserting the above WSGIPythonPath

推荐答案

添加

WSGIPythonPath /path/to/my/py/files/folder

在应用程序 conf 文件中的任何其他别名或目录之前确实有所不同.问题解决了!

before any other alias or directory in the application conf file really makes the difference. Problem solved!

这篇关于在 wsgi 中导入 python 模块时出现 500 内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆