部署后在django中使用scipy.stats.stats
我正在为一个严重依赖 scipy.stats.stats (scipy 版本 0.9.0)的包创建一个由 django 支持的(1.3)接口,称为 ovl 。在早期开发阶段,使用 djangos 自己的开发服务器,这没有问题。使用apache debian/2.2.9和mod_wsgi 3.3部署后,这会导致严重的问题。
无论我尝试在浏览器中加载什么视图,它都会开始加载,并持续加载 5 分钟(直到超时),然后出现 500 个页面。 仅导入 scipy 就可以,但是不能使 scipy.stats.stats 甚至 scipy.stats 可用。这并不奇怪。在 scipy 的 init.py 文档中指出,需要显式导入子包 stats
。然而,对于子包 cluster
也是如此,它在 django 中导入(从网络 和 django-shell 中的)没有任何问题,并且确实显示在 dir(scipy)
,它在 ipython(0.10.2) 会话中不会,它只是没有显示,就像我预期的那样。
在命令dir(scipy)
上;当来自网络(568 个字符串的列表,包括子包 cluster
)时,它在普通 ipython shell(564 个字符串,没有子包 cluster
)中返回不同的结果,令人惊讶令人惊讶的是,在 django shell 中。在 django shell 中,scipy 有 570 个属性,包括 cluster 和 stats 包。
另一件事是,如果我继续导入 ovl-package,同时将 scipy.stats 导入保持在一定距离(不在应用程序本身的一个文件中),有时我会得到一个ViewDoesNotExist 错误指出视图模块中没有方法索引,但显然有一个。这让我想起 这个。
所以现在我正在考虑这些相当丑陋的解决方案:
- 编辑 scipy 的 init 以导入 stats 包,以便它“正常”出现在 dir(scipy) 中,并且可以通过 scipy.stats 访问,我可以使用旧代码。
- 然而,抢夺 scipy 的 stat 子包并从中创建一个常规包(可能使用符号链接),
我不愿意应用这些解决方案。事实上集群出现在 django 环境中的 scipy 中让我有点担心。我想这可能与从网络登录时成为 www-data 用户有关,但我不知道如何检查。
还有其他人遇到过这个吗?这个的一部分? 或者其他有用的想法?
哦,另一个 django 部署确实可以工作。
I am in the process of creating an django-powered (1.3) interface to a package that relies heavily in scipy.stats.stats (scipy version 0.9.0), called ovl
. During early development phases, using djangos own development-server, this was no problem. After deployment using apache debian/2.2.9 and mod_wsgi 3.3, this causes a serious problem.
Whatever view I'm trying to load in the browser, it starts loading, and keeps doing that for a good 5 minutes (until time-out) and a 500 page appears.
Just importing scipy works but, does not make scipy.stats.stats or even scipy.stats available. This is no surprise; in the documentation in scipy's init.py it is stated that the subpackage stats
needs to be imported explicitly. However, the same is said about the subpackage cluster
, which imports in django (from the web and in the django-shell) without any problem and indeed shows up in dir(scipy)
, which it doesn't in an ipython(0.10.2)-session, where it just doesn't show up, like I kinda expected.
On the command dir(scipy)
; it returns different results when coming from the web (a list of 568 strings, including the subpackage cluster
) in the normal ipython shell (564 strings, no subpackage cluster
) and surprise, surprise, in the django shell. In the django shell scipy has 570 attributes, including both cluster
and stats
packages.
Another thing is, if I keep importing the ovl
-package, while keeping the scipy.stats imports at a bit of a distance (not in one of the files of the app itself), sometimes I get a ViewDoesNotExist error stating that there is no method index in the views module while there clearly is one. Which reminds me of this.
So now I'm thinking of these rather ugly solutions:
- Editing scipy's init to import the stats package so it appears 'normally' in dir(scipy) and is accessible through scipy.stats and I can use the old code.
- Snatching scipy's stat subpackage and making a regular package out of it (perhaps using a symlink)
I'm reluctant in applying these solutions, however. The fact cluster shows up in scipy in a django environment worries me a bit. I thought maybe this has something to do with being www-data user when logging in from the web, but I don't know how to check for that.
Did anyone else encounter this? Parts of this?
Or otherwise helpful thoughts?
Oh and another django deployment does work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
mod_python 曾经尝试在同一进程中使用多个Python解释器。 mod_wsgi 可能会做同样的事情。虽然这通常可以正常工作,但某些扩展模块不支持此功能。 scipy.stats 可能正在导入这样的扩展模块。我们在 scipy 邮件列表上也有关于 mod_python 下的 scipy.stats 的类似报告。检查 mod_wsgi 文档,看看是否可以对其进行配置,使其不在同一进程中使用多个解释器,或者找到一种不同的部署策略,为应用程序的每个进程使用一个解释器。
mod_python used to try using multiple Python interpreters in the same process. mod_wsgi might be doing the same. While this frequently works okay, some extension modules do not support this. scipy.stats is probably importing such an extension module. We have had similar reports on the scipy mailing list concerning scipy.stats under mod_python. Check the mod_wsgi documentation to see if you can configure it such that it does not use multiple interpreters in the same process, or find a different deployment strategy that uses one interpreter per process for the app.
当我在 django 应用程序中使用 scipy.stats 时,我也遇到了这个问题。
在 django manage.py runsever 环境中,我的应用程序正确执行,没有任何问题。但是当我使用 mod_python 将应用程序部署到 apache 服务器时,我无法进入我的应用程序,并且浏览器一直加载直到超时。在我删除应用程序中所有导入的 scipy.stats 语句后,问题就解决了,我可以在 apache 服务器中执行我的应用程序。
I also encounter this problem when I use scipy.stats in my django application.
In django manage.py runsever environment, my app is executed correctly without any problem. But when I deploy the app to apache server with mod_python, I can't enter my app, and the browser keep loading until the time out. After I remove all imported scipy.stats statements in my app, the problem is solved, and I can execute my app in the apache server.