Deploying Django on Windows server 2019 using xampp gives ModuleNotFoundError: No module named '_socket'\r
I am trying to host a django application on Windows Server 2019 using XAMPP and after going through all the settings necessary for the app to run, I get an Internal Server Error.
Here's my setup:
Running on venv, doing a pip freeze gives:
(envcrm)
DECRM@CRM2 MINGW64 /c/xampp/htdocs/crm
$ pip freeze
asgiref==3.6.0
Django==4.1.5
mod-wsgi==4.9.4
mysqlclient==2.1.1
sqlparse==0.4.3
tzdata==2022.7
Django App is in C:\xampp\htdocs\crm\decrm
Directory Structure:
C:\xampp\htdocs\crm
|--decrm -> python project
|--envcrm -> virtual environment
|--mydecrm -> app
|--static -> static folder for the apps
|--templates -> templates folder for the apps
|--users -> app
Also placed MOD_WSGI_APACHE_ROOTDIR in the environment variables to be able to do a successful
pip install mod_wsgi
As for the httpd.conf
, here's my setting for WSGI:
LoadFile "C:/Users/DECRM/AppData/Local/Programs/Python/Python311/python311.dll"
LoadModule wsgi_module "C:/xampp/htdocs/crm/envcrm/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp311-win_amd64.pyd"
WSGIPythonHome "C:/xampp/htdocs/crm/envcrm"
WSGIScriptAlias / "c:/xampp/htdocs/crm/decrm/wsgi.py"
WSGIPythonPath "c:/xampp/htdocs/crm"
<Directory "c:/xampp/htdocs/crm/decrm/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "c:/xampp/htdocs/crm/static/"
<Directory "c:/xampp/htdocs/crm/static/">
Require all granted
</Directory>
with this, I get an Internal Server Error with these on the error logs:
[Wed Jan 25 19:18:33.645848 2023] [wsgi:error] [pid 6720:tid 2060] [client ::1:51675] ModuleNotFoundError: No module named '_socket'\r
[Wed Jan 25 19:18:33.694850 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] mod_wsgi (pid=6720): Failed to exec Python script file 'C:/xampp/htdocs/crm/decrm/wsgi.py'., referer: http://localhost/
[Wed Jan 25 19:18:33.694850 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] mod_wsgi (pid=6720): Exception occurred processing WSGI script 'C:/xampp/htdocs/crm/decrm/wsgi.py'., referer: http://localhost/
[Wed Jan 25 19:18:33.697847 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] Traceback (most recent call last):\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:/xampp/htdocs/crm/decrm/wsgi.py", line 12, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] from django.core.wsgi import get_wsgi_application\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:\\xampp\\htdocs\\crm\\envcrm\\Lib\\site-packages\\django\\core\\wsgi.py", line 2, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] from django.core.handlers.wsgi import WSGIHandler\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:\\xampp\\htdocs\\crm\\envcrm\\Lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 3, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] from django.conf import settings\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:\\xampp\\htdocs\\crm\\envcrm\\Lib\\site-packages\\django\\conf\\__init__.py", line 19, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] from django.utils.deprecation import RemovedInDjango50Warning\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:\\xampp\\htdocs\\crm\\envcrm\\Lib\\site-packages\\django\\utils\\deprecation.py", line 1, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] import asyncio\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:\\Users\\DECRM\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\asyncio\\__init__.py", line 8, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] from .base_events import *\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:\\Users\\DECRM\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\asyncio\\base_events.py", line 23, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] import socket\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] File "C:\\Users\\DECRM\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\socket.py", line 51, in <module>\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] import _socket\r, referer: http://localhost/
[Wed Jan 25 19:18:33.698851 2023] [wsgi:error] [pid 6720:tid 2076] [client ::1:51674] ModuleNotFoundError: No module named '_socket'\r, referer: http://localhost/
I just don't know where to look from here, especially for the _socket
module.
Other details:
Apache/2.4.54 (Win64)
mod_wsgi/4.9.4
Python/3.11
Anything I might have missed or have been setting incorrectly? Thanks in advance for the help!