using scipy in django with apache and mod_wsgi

余生长醉 提交于 2019-12-10 03:57:59

问题


I have defined a django view that uses scipy.optimize.curve_fit. This works without problems using the django development server, but when I deploy the Django application with Apache and mod_wsgi the view function gets stuck importing curve_fit:

from scipy.optimize import curve_fit

When this line is removed the rest of the app works well on the Apache server. Why does this line not work with Apache and mod_wsgi?


回答1:


In your WSGI file you will have something that looks like this:

<VirtualHost>
    ...
    WSGIScriptAlias / /somepath/deployment/wsgi/yoursite.wsgi
</VirtualHost>

You need to add the following line:

<VirtualHost>
    ...
    WSGIScriptAlias / /somepath/deployment/wsgi/yoursite.wsgi
    WSGIApplicationGroup %{GLOBAL}
</VirtualHost>

The explanation for that can be found here:

http://mail.scipy.org/pipermail/scipy-user/2011-November/031014.html




回答2:


many thanks for this post. I had the same Problem with spaCy and fixed it by the

<VirtualHost>
    …

    WSGIApplicationGroup %{GLOBAL}
</VirtualHost>


来源:https://stackoverflow.com/questions/16823388/using-scipy-in-django-with-apache-and-mod-wsgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!