Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 472
Sxkaur Avatar asked Nov 19 '12 19:11

Sxkaur


2 Answers

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.

like image 79
Sxkaur Avatar answered Nov 03 '22 22:11

Sxkaur


Try to include/add directory "C:\Python27\DLLs" to your PYTHONPATH environment variable. This solve the problem of _socket on my system. if you check the folder there are some files there including _socket.pyd

like image 44
Master p Avatar answered Nov 03 '22 22:11

Master p