pythonapacheflaskmod-wsgimodulenotfounderror

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


I'm using mod_wsgi with python 3.11.4 64bit and apache 2.4.58 win64 VS17 on windows 11 pro.

And I install python for everyon not just for me.

In addition I do not use python virtualenv.

When I run without apache(mod_wsgi standard alone) there is no probelm. mod_wsgi-express start-server server.wsgi --port 5000

But when I use with httpd I got a ModuleNotFoundError message like below

[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

It seems like I don't have dateutil module but accually I already installed python-dateutil and I have used pandas so many times.( in my pc there are only one python environment)

I don't know why I got ModuleNotFoundError when I use httpd with mod_wsgi.

please let me know what should check to solve this problem.

Thank you a lot.

-- here is httpd code --

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>

I tried import dateutil in another environment such as jupyter notebook or python idle. And then I don't any error of import dateutil in python even pandas also.


Solution

  • I soled this error. The reason why I got problem is there are two site-packege path for module. I'm not sure but mayby I installed python more than twice. I found pandas module instllaed in for everyone python path but dateutil install in user roaming path.