关于 mod_wsgi ModuleNotFoundError (dateutil) // python 3.11.4 64bit 和 apache 2.4.58 win64 VS17

about mod_wsgi ModuleNotFoundError (dateutil) // python 3.11.4 64bit and apache 2.4.58 win64 VS17

提问人:student 提问时间:10/24/2023 最后编辑:student 更新时间:10/24/2023 访问量:32

问:

我在 Windows 3.11.4 pro 上将 mod_wsgi 与 python 3.11.4 64 位和 apache 2.4.58 win64 VS17 一起使用。

而且我为每个人安装 python,而不仅仅是为了我。

此外,我不使用 python virtualenv。

当我在没有apache(仅mod_wsgi标准)的情况下运行时,没有问题。mod_wsgi-express start-server server.wsgi --port 5000

但是当我与 httpd 一起使用时,我收到了如下所示的 ModuleNotFoundError 消息

[Mon Oct 23 16:23:56.361855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591] mod_wsgi (pid=29624): Failed to exec Python script file 'C:/Users/KORLOY/workspace/00_flask/aps_ed_project/server.wsgi'.
[Mon Oct 23 16:23:56.361855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591] mod_wsgi (pid=29624): Exception occurred processing WSGI script 'C:/Users/KORLOY/workspace/00_flask/aps_ed_project/server.wsgi'.
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591] Traceback (most recent call last):\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]   File "C:/Users/KORLOY/workspace/00_flask/aps_ed_project/server.wsgi", line 4, in <module>\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]     application = create_app()\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]                   ^^^^^^^^^^^^\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]   File "C:\\Users\\KORLOY\\workspace\\00_flask\\aps_ed_project\\dashboard\\__init__.py", line 5, in create_app\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]     from .views import main_views\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]   File "C:\\Users\\KORLOY\\workspace\\00_flask\\aps_ed_project\\dashboard\\views\\main_views.py", line 16, in <module>\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]     import pandas as pd\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]   File "C:\\python\\python_3.11.4_64bit\\Lib\\site-packages\\pandas\\__init__.py", line 29, in <module>\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591]     raise ImportError(\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591] ImportError: Unable to import required dependencies:\r
[Mon Oct 23 16:23:56.362855 2023] [wsgi:error] [pid 29624:tid 1164] [client 192.168.12.146:60591] dateutil: No module named 'dateutil'\r

似乎我没有 dateutil 模块,但我已经安装了 python-dateutil,并且我已经多次使用 pandas。(在我的电脑中只有一个 Python 环境)

我不知道为什么当我将 httpd 与 mod_wsgi 一起使用时,我得到了 ModuleNotFoundError。

请让我知道应该检查什么来解决这个问题。

非常感谢。

-- 这里是 httpd 代码 --

Listen 80
Listen 5000

LoadFile "C:\python\python_3.11.4_64bit\python311.dll"
LoadModule wsgi_module "C:\python\python_3.11.4_64bit\Lib\site-packages\mod_wsgi\server\mod_wsgi.cp311-win_amd64.pyd"
WSGIPythonHome "C:\python\python_3.11.4_64bit"

ServerName localhost
# for flask server
<VirtualHost  *:5000>
    ServerName localhost
    WSGIScriptAlias / C:/Users/KORLOY/workspace/00_flask/aps_ed_project/server.wsgi
    #DocumentRoot C:/Users/KORLOY/workspace/00_flask/aps_ed_project
    <Directory C:/Users/KORLOY/workspace/00_flask/aps_ed_project>
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>
</VirtualHost>

我尝试在另一个环境中导入 dateutil,例如 jupyter notebook 或 python idle。然后我也没有在 python 中导入 dateutil 的任何错误,甚至是 pandas。

python apache flask mod-wsgi modulenotfounderror

评论

0赞 student 10/25/2023
我解决了这个错误。我遇到问题的原因是模块有两个站点打包路径。我不确定,但也许我安装了 python 两次以上。我发现 pandas 模块为每个人提供了 python 路径,但 dateutil install 在用户漫游路径中。

答: 暂无答案