Django, mod_wsgi, psycopg2 ImproperlyConfigured: Error loading psycopg2 module: No module named _psycopg [英] Django, mod_wsgi, psycopg2 ImproperlyConfigured: Error loading psycopg2 module: No module named _psycopg

查看:63
本文介绍了Django, mod_wsgi, psycopg2 ImproperlyConfigured: Error loading psycopg2 module: No module named _psycopg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 Apache 下运行的 Django 1.5、Python 2.7 站点,在 CentOS 6.4 服务器上使用 mod_wsgi.

I have a Django 1.5, Python 2.7 site running under Apache with mod_wsgi on a CentOS 6.4 server.

我使用 Django 1.6 和 Python 3.3 重建了这个网站.将其部署到同一台服务器并更改 httpd.conf 中的路径,我收到了主题错误.这个新安装使用 ./manage.py runserver 按预期工作.

I have rebuilt this site using Django 1.6 and Python 3.3. Deploying it to the same server and changing the paths in httpd.conf I get the subject error. This new install works as expected using ./manage.py runserver.

以下是 httpd.conf 中的两个 WSGI 定义:

Here are the two WSGI definitions from httpd.conf:

WSGIScriptAlias / /home/ccdgen/CCDGEN2/apache/wsgi.py
WSGIPythonPath         /home/ccdgen/CCDGEN2/ccdgen/ccdgen:/home/ccdgen/CCDGEN2/ccdgen:/home/ccdgen/CCDGEN2/lib/python3.3/site-packages
<Directory /home/ccdgen/CCDGEN2/ccdgen>
   <Files wsgi.py>
     Order allow,deny
     Allow from all
   </Files>
</Directory>

#WSGIScriptAlias /ccdgen /home/ccdgen/CCDGEN/apache/wsgi.py
#WSGIPythonPath /home/ccdgen/CCDGEN/mlhim/ccdgen:/home/ccdgen/CCDGEN/mlhim:/home/ccdgen/CCDGEN/lib/python2.7/site-packages
#<Directory /home/ccdgen/CCDGEN/mlhim>
#   <Files wsgi.py>
#     Order allow,deny
#     Allow from all
#   </Files>
#</Directory>

wsgi.py 文件在两个安装中是相同的:

The wsgi.py file is the same on both installations:

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mlhim.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

有什么想法吗?明显的疏忽?谢谢

Any ideas? Obvious oversights? Thanks

推荐答案

问题是 mod_wsgi 是为 Python 2.7 编译的,需要为 Python 3.3 重新编译.我没有在任何地方找到一个新的 mod_wsgi 包,所以我重新编译了它.

The problem was that mod_wsgi was compiled for Python 2.7 and it needed to be recompiled for Python 3.3. I did not find a new mod_wsgi available anywhere as a package so I recompiled it.

由于 Python 3 是 CentOS 6.4 上的备用安装,因此 .configure 很难生成好的 M​​akefile,甚至传递了 --with-python 选项.从 python3.3-config --cflags 和 --ldflags 选项获取信息后,我需要稍微编辑 Makefile.

Since Python 3 is an alternate install on CentOS 6.4 .configure had a difficult time producing a good Makefile, even passing the --with-python option. I needed to edit Makefile a bit after getting the information from python3.3-config --cflags and also with --ldflags options.

HTH 未来的某个人.

HTH someone in the future.

这篇关于Django, mod_wsgi, psycopg2 ImproperlyConfigured: Error loading psycopg2 module: No module named _psycopg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆