导入 psycopg2 :系统错误:_psycopg 的初始化引发了未报告的异常 第二个 URL 失败

问题描述 投票:0回答:1

我的应用程序有两个 url,它们引用相同的 URL,例如:localhost:8080 和 abc.com。模式是,重新启动 apache 服务器后,只有我首先点击的第一个 URL 有效,而第二个 URL 不起作用。理想情况下,两者都应该工作,因为两者都引用同一服务器。

我在 python 3.9 中遇到以下错误。在遵循 this 之后,我使用 python 3.9 pip 卸载并安装了 mod_wsgi 4.7.1,并使用

mod_wsgi-express.exe module-config

的输出更新了 apache httpd.conf
[Mon May 24 04:31:30.115963 2021] [mpm_winnt:notice] [pid 8560:tid 104] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Mon May 24 04:31:32.121364 2021] [mpm_winnt:notice] [pid 9452:tid 904] AH00364: Child: All worker threads have exited.
[Mon May 24 04:31:32.303380 2021] [mpm_winnt:notice] [pid 8560:tid 104] AH00430: Parent: Child process 9452 exited successfully.
[Mon May 24 04:31:33.770657 2021] [mpm_winnt:notice] [pid 612:tid 908] AH00455: Apache/2.4.46 (Win64) mod_wsgi/4.7.1 Python/3.9 configured -- resuming normal operations
[Mon May 24 04:31:33.771659 2021] [mpm_winnt:notice] [pid 612:tid 908] AH00456: Apache Lounge VS16 Server built: Mar 27 2021 11:42:37
[Mon May 24 04:31:33.771659 2021] [core:notice] [pid 612:tid 908] AH00094: Command line: 'F:\\Program Files\\NGDM\\Apache24\\bin\\httpd.exe -d F:/Program Files/NGDM/Apache24'
[Mon May 24 04:31:33.781650 2021] [mpm_winnt:notice] [pid 612:tid 908] AH00418: Parent: Created child process 10632
[Mon May 24 04:31:34.815778 2021] [mpm_winnt:notice] [pid 10632:tid 872] AH00354: Child: Starting 64 worker threads.
[Mon May 24 04:32:18.161398 2021] [wsgi:error] [pid 10632:tid 1440] RUN_ID==>51683<==\r
[Mon May 24 04:32:18.163398 2021] [wsgi:error] [pid 10632:tid 1440] RUN_ID==>51683<==\r
C:\A\34\s\Modules\_decimal\libmpdec\context.c:57: warning: mpd_setminalloc: ignoring request to set MPD_MINALLOC a second time

[Mon May 24 04:32:29.651626 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] mod_wsgi (pid=10632): Failed to exec Python script file 'F:/XYZ/test_wsgi.wsgi'.
[Mon May 24 04:32:29.651626 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] mod_wsgi (pid=10632): Exception occurred processing WSGI script 'F:/XYZ/test_wsgi.wsgi'.
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] Traceback (most recent call last):\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202]   File "F:/XYZ/test_wsgi.wsgi", line 6, in <module>\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202]     from app_e1 import app as application\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202]   File "f:/XYZ\\app_e1.py", line 6, in <module>\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202]     import psycopg2\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202]   File "c:\\python39\\lib\\site-packages\\psycopg2\\__init__.py", line 51, in <module>\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202]     from psycopg2._psycopg import (                     # noqa\r
[Mon May 24 04:32:29.661629 2021] [wsgi:error] [pid 10632:tid 1440] [client 148.173.41.4:61202] SystemError: initialization of _psycopg raised unreported exception\r
python-3.x psycopg2 mod-wsgi
1个回答
0
投票

就我而言,在 httpd.conf 中添加以下行后重新启动服务器修复了多个 python 子解释器的问题。 参考

WSGIApplicationGroup %{GLOBAL}
© www.soinside.com 2019 - 2024. All rights reserved.