我使用 python3.4 在 centos7 中运行 Django 应用程序。我正在使用 apache 作为网络服务器。但是我收到以下错误:
[Tue Dec 05 09:48:17.048763 2017] [:error] [pid 8470] [remote 103.194.69.2:100] mod_wsgi (pid=8470): Target WSGI script '/var/www/hello_world_django/hello_world_django/wsgi.py' cannot be loaded as Python module.
[Tue Dec 05 09:48:17.049021 2017] [:error] [pid 8470] [remote 103.194.69.2:100] mod_wsgi (pid=8470): Exception occurred processing WSGI script '/var/www/hello_world_django/hello_world_django/wsgi.py'.
[Tue Dec 05 09:48:17.049272 2017] [:error] [pid 8470] [remote 103.194.69.2:100] Traceback (most recent call last):
[Tue Dec 05 09:48:17.049383 2017] [:error] [pid 8470] [remote 103.194.69.2:100] File "/var/www/hello_world_django/hello_world_django/wsgi.py", line 13, in <module>
[Tue Dec 05 09:48:17.049625 2017] [:error] [pid 8470] [remote 103.194.69.2:100] from django.core.wsgi import get_wsgi_application
[Tue Dec 05 09:48:17.049661 2017] [:error] [pid 8470] [remote 103.194.69.2:100] File "/var/www/virtual/lib/python3.4/site-packages/django/__init__.py", line 1, in <module>
[Tue Dec 05 09:48:17.049711 2017] [:error] [pid 8470] [remote 103.194.69.2:100] from django.utils.version import get_version
[Tue Dec 05 09:48:17.049735 2017] [:error] [pid 8470] [remote 103.194.69.2:100] File "/var/www/virtual/lib/python3.4/site-packages/django/utils/version.py", line 61, in <module>
[Tue Dec 05 09:48:17.049777 2017] [:error] [pid 8470] [remote 103.194.69.2:100] @functools.lru_cache()
[Tue Dec 05 09:48:17.049901 2017] [:error] [pid 8470] [remote 103.194.69.2:100] AttributeError: 'module' object has no attribute 'lru_cache'
python3.4 的 mod_wsgi 似乎存在一些问题。为了检查我是否使用 python2.7 尝试过它并且它适用于 pythyon2.7。
我在centos 中找不到python3.4 的mod_wsgi 包。任何问题如何解决这个问题????
这是我的 apache conf
Listen 8080
# Django settings
WSGIDaemonProcess django_com user=apache group=apache processes=1 threads=10 python-path=/var/www/sample:/var/www/sample_env/lib/python2.7/site-packages
WSGIProcessGroup django_com
WSGIScriptAlias / /var/www/sample/sample/wsgi.py
<Directory /var/www/sample>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
最佳答案
要让 Python 3.4 与 CentOS 中的 mod_wsgi 一起工作,假设您从 EPEL 安装了 Python 3.4(和 pip),您可以这样做:yum install httpd-devel
(你需要这个来让 mod_wsgi 的 pip 安装工作)pip3 install mod-wsgi
mod_wsgi-express install-module > /etc/httpd/conf.modules.d/02-wsgi.conf
关于apache - python3.4的httpd mod_wsgi在centos7中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47650902/