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

前端 未结 4 1689
滥情空心
滥情空心 2020-12-17 21:49

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

I have rebuilt this site using Django 1.6 and Python 3.3. Deploying

相关标签:
4条回答
  • 2020-12-17 22:08

    As has been mentioned, mod_wsgi has not been compiled for python 3. One option is to use Software Collections and/or go with nginx, and "pip install uwsgi" which saves a lot of compiling and running custom packages.

    0 讨论(0)
  • 2020-12-17 22:13

    I had this problem recently:

    ImproperlyConfigured: Error loading psycopg2 module: No module named _psycopg

    ... and this command was the answer:

    sudo apt-get install libapache2-mod-wsgi-py3

    Reference:

    http://python.6.x6.nabble.com/ImproperlyConfigured-Error-loading-psycopg2-module-No-module-named-psycopg-td5044145.html

    0 讨论(0)
  • 2020-12-17 22:25

    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.

    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 someone in the future.

    0 讨论(0)
  • 2020-12-17 22:32

    Try these commands Debian, Ubuntu

    sudo apt-get install python-dev
    sudo apt-get install libpq-dev
    

    For RedHat Enterprise, Fedora, CentOS

    sudo yum install python-devel
    sudo yum install postgresql-libs
    

    Then Install psycopg2

    pip install psycopg2
    
    0 讨论(0)
提交回复
热议问题