部署后在django中使用scipy.stats.stats [英] Using scipy.stats.stats in django after deployment

查看:134
本文介绍了部署后在django中使用scipy.stats.stats的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一个很大程度上依赖于scipy.stats.stats(scipy版本0.9.0)的程序包创建了一个django-powered(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 。然而,关于在django(从django-shell中的web )中导入的子包集群也是一样的,没有任何问题,确实出现在 dir(scipy)中,它在ipython(0.10.2)-session中不,它只是在'在我想要的时候,显示出来。



在命令 dir(scipy)在正常的ipython shell(564字符串,没有子包集群)返回不同的结果>集群)和惊喜,在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数据用户从网络登录有关,但我不知道如何检查。



有没有人遇到这个?这部分?
否则有帮助的想法?



哦,另一个django部署的工作。

解决方案

mod_python用于在同一个进程中尝试使用多个Python解释器。 mod_wsgi可能也是这样做的。虽然这通常工作正常,一些扩展模块不支持这一点。 scipy.stats可能是导入这样一个扩展模块。我们在mod_python下有关于scipy.stats的scipy邮件列表的类似报告。检查mod_wsgi文档以查看是否可以进行配置,使其不会在同一进程中使用多个解释器,或者找到针对应用程序每个进程使用一个解释器的不同部署策略。


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.

解决方案

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.stats的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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