I am using WSGI 3.3 for python 2.7.3 (32bit) for Apache 2.2. I got the binary WSGI from http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-win32-ap22py27-3.3.so. 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/mod_vhost_alias.so
LoadModule wsgi_module modules/mod_wsgi.so

<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\\wsgi.py", 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\\__init__.py", 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\\urllib.py", 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\\socket.py", 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
  • 1
    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 brettweiss.wordpress.com/2008/11/28/… – 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

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.

| improve this answer | |
  • I was able to get it to work by adding "C:/Python36/DLLs" to the WSGIPythonPath in the Apache configuration file. – Bobort Aug 30 '17 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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