Django 和 mod_wsgi 安装突然停止工作

Django and mod_wsgi installation suddenly stopped working

我有一个脚本,用于使用 django 1.9.6mod_wsgi 在虚拟机上安装我的应用程序。它至少可以正常工作一年,然后几个月后我就没有使用它了——它突然不工作了。我总是在一个干净的 ubuntu 可信图像上安装,我没有做任何更改。所以我的猜测是 apt-get 现在正在安装不同版本的 libapache2-mod-wsgi

sudo apt-get update
sudo apt-get install -y python-pip
sudo pip install django=1.9.6
sudo pip install python-social-auth
sudo apt-get -y install apache2 libapache2-mod-wsgi
...

当我尝试 运行 应用程序时,apache 服务器给出错误:

[Tue Oct 17 11:52:29.184072 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385] mod_wsgi (pid=8178): Target WSGI script '/root/geosearch_app/geosearch_project/geosearch_project/wsgi.py' cannot be loaded as Python module.
[Tue Oct 17 11:52:29.184116 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385] mod_wsgi (pid=8178): Exception occurred processing WSGI script '/root/geosearch_app/geosearch_project/geosearch_project/wsgi.py'.
[Tue Oct 17 11:52:29.184140 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385] Traceback (most recent call last):
[Tue Oct 17 11:52:29.184159 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]   File "/root/geosearch_app/geosearch_project/geosearch_project/wsgi.py", line 16, in <module>
[Tue Oct 17 11:52:29.184212 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]     application = get_wsgi_application()
[Tue Oct 17 11:52:29.184225 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]   File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Tue Oct 17 11:52:29.184266 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]     django.setup()
[Tue Oct 17 11:52:29.184280 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Tue Oct 17 11:52:29.184327 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]     apps.populate(settings.INSTALLED_APPS)
[Tue Oct 17 11:52:29.184339 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
[Tue Oct 17 11:52:29.184458 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]     app_config.import_models(all_models)
[Tue Oct 17 11:52:29.184471 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]   File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 202, in import_models
[Tue Oct 17 11:52:29.184549 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]     self.models_module = import_module(models_module_name)
[Tue Oct 17 11:52:29.184561 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Tue Oct 17 11:52:29.184738 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]     __import__(name)
[Tue Oct 17 11:52:29.184751 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]   File "/usr/local/lib/python2.7/dist-packages/social/apps/django_app/default/models.py", line 1, in <module>
[Tue Oct 17 11:52:29.184791 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385]     from social_django.models import AbstractUserSocialAuth, UserSocialAuth, Nonce, Association, Code, DjangoStorage
[Tue Oct 17 11:52:29.184819 2017] [:error] [pid 8178:tid 140000402241280] [remote 131.111.64.116:33385] ImportError: No module named social_django.models
[Tue Oct 17 11:52:29.289697 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169] mod_wsgi (pid=8178): Target WSGI script '/root/geosearch_app/geosearch_project/geosearch_project/wsgi.py' cannot be loaded as Python module.
[Tue Oct 17 11:52:29.289725 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169] mod_wsgi (pid=8178): Exception occurred processing WSGI script '/root/geosearch_app/geosearch_project/geosearch_project/wsgi.py'.
[Tue Oct 17 11:52:29.289745 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169] Traceback (most recent call last):
[Tue Oct 17 11:52:29.289768 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]   File "/root/geosearch_app/geosearch_project/geosearch_project/wsgi.py", line 16, in <module>
[Tue Oct 17 11:52:29.289799 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]     application = get_wsgi_application()
[Tue Oct 17 11:52:29.289809 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]   File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Tue Oct 17 11:52:29.289827 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]     django.setup()
[Tue Oct 17 11:52:29.289836 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]   File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Tue Oct 17 11:52:29.289850 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]     apps.populate(settings.INSTALLED_APPS)
[Tue Oct 17 11:52:29.289859 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]   File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Tue Oct 17 11:52:29.289873 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169]     raise RuntimeError("populate() isn't reentrant")
[Tue Oct 17 11:52:29.289891 2017] [:error] [pid 8178:tid 140000419026688] [remote 131.111.64.116:24169] RuntimeError: populate() isn't reentrant

我希望在不实际更改任何东西的情况下解决这个问题,除了安装脚本,它应该可以工作,因为它以前工作过。

有什么建议吗?

参见:

您似乎安装了更新版本的软件包,它对安装有不同的要求,需要安装额外的软件包。

您可能希望将该包固定到您之前使用的相同旧版本,否则您可能需要对您的代码和数据库进行其他更改。