Apache ImportError: No module named _socket in wsgi deployment on Django

Sxkaur picture Sxkaur · Nov 19, 2012 · Viewed 7.8k times · Source

I am using WSGI 3.3 for Python 2.7.3 (32bit) for Apache 2.2. I downloaded the wsgi from http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-win32-ap22py27-3.3.so and just renamed it and transferred it to the APACHE modules.

I have been trying to deploy an application but keep on receiving the ImportError: no module named _socket. I have included my wsgi and error logs.

I am not sure as to what I am doing wrong. I thought maybe I could include a PythonPath but am not sure. I can try to provide more information if needed. Thank you in advance.

APACHE CONFIG:

LoadModule wsgi_module modules/mod_wsgi.so

<Directory C:/Users/xxxxd/Documents/cahd>
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias / C:/Users/xxxxd/Documents/cahd/cahd/django.wsgi

WSGI FIle:

import os, sys    
sys.path.append('C:/Users/xxxxd/Documents)
sys.path.append('C:/Users/xxxxd/Documents/cahd/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'cahd.settings'
import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler()

The error was:

[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] Traceback (most recent call last):
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] File "C:/Users/xxxxd/Documents/cahd/django.wsgi", line 10, in 
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] import django.core.handlers.wsgi
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] File "C:\django\Django-1.4.1\django\core\handlers\wsgi.py", line 8, in 
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] from django import http
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] File "C:\django\Django-1.4.1 \django\http\_init_.py", line 11, in 
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] from urllib import urlencode, quote
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] File "C:\Python27\Lib\urllib.py", line 26, in 
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] import socket
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] File "C:\Python27\Lib\socket.py", line 47, in 
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] import _socket
[Mon Nov 19 09:44:17 2012] [error] [client 127.0.0.1] ImportError: No module named _socket

Answer

Sxkaur picture Sxkaur · Nov 30, 2012

Although reinstalling python might have worked. I figured out that _socket was a _socket.pyd file located in the DLLs folder, by adding that to my pythonpath in windows I was able to make my application work. Thank you for everyone's help.