0

Trying to deploy a django project on apache (2.2) on Debian 7. Using Django 1.8 and a virtual environment with python3.4.

Getting the following error:

django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named _psycop

I have tried the suggestions pointed out here, and here.

Here is my apache conf.

(following lines are nested within VirtualHost scope)

#WSGI configuration for ds_monitor django project

Alias /static /home/pkaramol/Applications/timeds/ds_monitor/static_root
<Directory /home/pkaramol/Applications/timeds/ds_monitor/static_root>
    Allow from all
</Directory>

<Directory /home/pkaramol/Applications/timeds/ds_monitor/ds_monitor>
    <Files wsgi.py>
        Allow from all
   </Files>
</Directory>

WSGIDaemonProcess ds_monitor python-path=/home/pkaramol/Applications/timeds/ds_monitor:/home/pkaramol/Applications/timeds/venv_p34dj18/lib/python3.4/site-packages
WSGIProcessGroup ds_monitor
WSGIScriptAlias /ds_monitor  /home/pkaramol/Applications/timeds/ds_monitor/ds_monitor/wsgi.py

and this outside VirtualHost scope (to enable production - time virtual environment)

WSGIPythonPath /home/pkaramol/Applications/timeds/ds_monitor:/home/pkaramol/Applications/timeds/venv_p34dj18/lib/python3.4/site-packages

Another issue is the following line present in apache's log stack trace

 File "/usr/lib/python3.2/importlib/_bootstrap.py", line 821, in _gcd_import
    loader.load_module(name)

Why is it using system's python 3.2?

Have I done s.th wrong in terms of pointing the virtualenv path correctly in wsgi confs?

In any case, the psycopg2 module is also installed in the system (not only in virtualenv)

Community
  • 1
  • 1
pkaramol
  • 16,451
  • 43
  • 149
  • 324

1 Answers1

0

Seems very weird but the whole issue most likely had to do with the python version that mod_wsgi was compiled against.

I had downloaded / configured / installed version 4.5.2 of mod_wsgi from here but forgot to configure with the appropriate python version.

So I run through the whole process again (starting from unzipping the original tarball) and configuring as follows:

./configure --with-python=/usr/bin/python3.5

Restarted apache and problem solved.

pkaramol
  • 16,451
  • 43
  • 149
  • 324