Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using WSGI 3.3 for python 2.7.3 (32bit) for Apache 2.2. I got the binary WSGI from 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.

APACHE config:

#LoadModule vhost_alias_module modules/
LoadModule wsgi_module modules/

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

WSGIScriptAlias / C:/Users/xxxxd/Documents/cahd/cahd/django.wsgi import os, sys


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] Traceback (most recent call last):
[Mon Nov 19 09:44:17 2012] [error] [client ]File "C:/Users/xxxxd/Documents/cahd/django.wsgi", line 10, in <module>
[Mon Nov 19 09:44:17 2012] [error] [client] import django.core.handlers.wsgi
[Mon Nov 19 09:44:17 2012] [error] [client] File "C:\\django\\Django-1.4.1\\django\\core\\handlers\\", line 8, in <module>
[Mon Nov 19 09:44:17 2012] [error] [client] from django import http
[Mon Nov 19 09:44:17 2012] [error] [client] File "C:\\django\\Django-1.4.1\\django\\http\\", line 11, in <module>
[Mon Nov 19 09:44:17 2012] [error] [client] from urllib import urlencode, quote
[Mon Nov 19 09:44:17 2012] [error] [client] File "C:\\Python27\\Lib\\", line 26, in <module>
[Mon Nov 19 09:44:17 2012] [error] [client] import socket
[Mon Nov 19 09:44:17 2012] [error] [client] File "C:\\Python27\\Lib\\", line 47, in <module>
[Mon Nov 19 09:44:17 2012] [error] [client] import _socket
[Mon Nov 19 09:44:17 2012] [error] [client] ImportError: No module named _socket
share|improve this question
There should be more to the error than that - it should tell you what file and line number is trying to do the failing import. – Shane Madden Nov 19 '12 at 17:57
I've added more of the error log. – Sxkaur Nov 19 '12 at 18:16
See the Windows Event Viewer and… – rorycl Nov 19 '12 at 20:00
I can run it on the development server. In addition, my helloworld.wsgi works on apache. However, when I config it to my application, it creates an error. Thank you anyway... – Sxkaur Nov 19 '12 at 21:03
Your hello world WSGI isn't trying to import 'socket'. Change it so it does and you will likely see the same error. – Graham Dumpleton Nov 20 '12 at 1:22
up vote 0 down vote accepted

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. The program was looking for a _socket in the wrong folder.Thank you for everyone's help.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.