ImproperlyConfigured: Error loading psycopg2 module: No module named _psycopg

432 views
Skip to first unread message

Timothy W. Cook

unread,
Jan 16, 2014, 5:34:19 AM1/16/14
to django...@googlegroups.com
This question is also on Stackoverflow http://goo.gl/LinMue  but I thought somene here may have an idea.


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 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.

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>

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()

----------------------------------------------------------------------------------------------

Thanks in advance for any ideas.

Cheers,
Tim


--
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

Начаров Михаил

unread,
Jan 16, 2014, 10:52:47 PM1/16/14
to django...@googlegroups.com
Hi Timothy,

Note that your mod_wsgi module compiled for using python2.7. So what you need now is install(compile&install) mod_wsgi for python3 instead of the same module compiled for python2.7.
On Debian you can do it by this command:
    $ sudo apt-get install libapache2-mod-wsgi-py3



16.01.2014 16:34, Timothy W. Cook пишет:
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3XNi7-FGOCPnKS%2Bb6%3D-ueWbPMOWFXfOce663fn0YpjWwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Timothy W. Cook

unread,
Jan 17, 2014, 4:34:30 AM1/17/14
to django...@googlegroups.com
On Fri, Jan 17, 2014 at 1:52 AM, Начаров Михаил <michael....@gmail.com> wrote:
Hi Timothy,

Note that your mod_wsgi module compiled for using python2.7. So what you need now is install(compile&install) mod_wsgi for python3 instead of the same module compiled for python2.7.
On Debian you can do it by this command:
    $ sudo apt-get install libapache2-mod-wsgi-py3


Thanks,  After some poking around, I did find that this was the problem.  Now, recompiling it on CentOS (with Python 3 as an alternate install) was quite another trick.  :-)  

Thanks.
 

For more options, visit https://groups.google.com/groups/opt_out.

Начаров Михаил

unread,
Jan 17, 2014, 5:14:19 AM1/17/14
to django...@googlegroups.com
You're welcome!

You can also take a look to another python web-server.
Especially if you want to have for example two sites with different version of python on the same server.
When I wrote my first django-app on py3, I faced the same problem.


17.01.2014 15:34, Timothy W. Cook пишет:
Reply all
Reply to author
Forward
0 new messages