我在Apache 2.2中使用WSGI 3.3 for Python 2.7.3(32位)。我从http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-win32-ap22py27-3.3.so下载了wsgi,并将其重命名并将其传输到APACHE模块。
我一直在尝试部署应用程序,但继续接收ImportError: no module named _socket
。我已经包含了我的wsgi和错误日志。
我不确定我做错了什么。我想也许我可以包含一个PythonPath但不确定。如果需要,我可以尝试提供更多信息。提前谢谢。
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()
错误是:
[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
答案 0 :(得分:14)
虽然重新安装python可能有效。我发现_socket是一个位于DLLs文件夹中的_socket.pyd文件,通过在我的pythonpath中添加它可以使我的应用程序工作。谢谢大家的帮助。
答案 1 :(得分:3)
尝试包含/添加目录&#34; C:\ Python27 \ DLLs&#34;到您的PYTHONPATH环境变量。这解决了我系统上_socket的问题。如果你检查文件夹,那里有一些文件,包括_socket.pyd
答案 2 :(得分:0)
您好我在重新安装Django和Python2.7.3时遇到了这个问题,这让我困扰了近2个小时。最后,我通过删除Python 2.7.3解决了这个问题,但安装了Python 2.7.6。希望它也适合你,祝你好运!