使用WSGI时导入Python模块

时间:2015-11-29 18:37:12

标签: python wsgi

我刚刚在Apache上安装了WSGI,开始使用Python作为Web编程语言。我只将此行添加到我的Apache配置中(除了加载mod_wsgi模块)

WSGIScriptAlias MyApp/ /path/to/app.wsgi

我的app.wsgi运行良好,但我想使用单独的文件来实现单独的功能。所以,我在与extras.py相同的目录中创建了app.wsgi,其中没有太多内容:

class MyClass:
     pass

然后放一个

from extras import MyClass

位于app.wsgi的顶部。但是,不幸的是,我收到了这个错误:

ImportError: cannot import name MyClass

我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

使用WSGIPythonPath指定运行ur wsgi应用程序时要搜索的模块。

有关它的更多信息,请here