python托管django应用程序时wsgi语法无效

u0sqgete  于 2023-08-08  发布在  Go
关注(0)|答案(2)|浏览(112)

我正在使用Django 4.2.2python 3.10,在AWS上托管服务器时,wsgy.py出现语法错误。
这是我在error.log中得到的

[wsgi:error]   mod_wsgi (pid=2084): Failed to exec Python script file '/var/www/project/wshp/wshp/wsgi.py'.
[wsgi:error]   mod_wsgi (pid=2084): Exception occurred processing WSGI script '/var/www/project/wshp/wshp/wsgi.py'.
[wsgi:error]   Traceback (most recent call last):
[wsgi:error]     File "/var/www/project/wshp/wshp/wsgi.py", line 13, in <module>
[wsgi:error]       from django.core.wsgi import get_wsgi_application
[wsgi:error]     File "/var/www/project/wshp/Env/lib/python3.10/site-packages/django/__init__.py", line 1, in <module>
[wsgi:error]       from django.utils.version import get_version
[wsgi:error]     File "/var/www/project/wshp/Env/lib/python3.10/site-packages/django/utils/version.py", line 7, in <module>
[wsgi:error]       from django.utils.regex_helper import _lazy_re_compile
[wsgi:error]     File "/var/www/project/wshp/Env/lib/python3.10/site-packages/django/utils/regex_helper.py", line 10, in <module>
[wsgi:error]       from django.utils.functional import SimpleLazyObject
[wsgi:error]     File "/var/www/project/wshp/Env/lib/python3.10/site-packages/django/utils/functional.py", line 265
[wsgi:error]       if (_wrapped := self._wrapped) is empty:
[wsgi:error]                    ^
[wsgi:error]   SyntaxError: invalid syntax

字符串
如果运行迁移或run server,则没有问题。
我看不出我必须升级什么,也不明白为什么这个get_wsgi_application不理解海象操作员。请帮助我理解我做错了什么。

ubof19bj

ubof19bj1#

运行Django应用程序的Python版本比Python 3.8更早。将Python版本升级到Python 3.8或Python 3.10之后,代码应该可以正常工作。

iyfjxgzm

iyfjxgzm2#

wsgi_mod必须**完全匹配Python的版本。**在我的案例中,CentOS 8 package managemet(dnf)无法确保Python 3.9的依赖。dnf显示wsgi_mod38和wsgi_mod39。用dnf手动适配修复了它。

相关问题