1

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
</Directory>

WSGIScriptAlias / C:/Users/xxxxd/Documents/cahd/cahd/django.wsgi 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 <module>
[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 <module>
[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 <module>
[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 <module>
[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 <module>
[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
Sxkaur
  • 11
  • 1
  • 4
  • 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 http://brettweiss.wordpress.com/2008/11/28/windows-vista-django-dll-issue-running-python-managepy-runserver/ – 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 01:22

1 Answers1

0

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.

Sxkaur
  • 11
  • 1
  • 4
  • 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 04:29