[Django]-Django project : production server, use python 3

2👍

So, after search and helps I’ve found how to make it works.
Why I answer ? Because @albar and @gbs both help me, and I want to make a ‘complete’ answer to help people who encounter this problem.

So first, @gbs was right, as I was not using the good wsgi app, it was looking in python 2.7 package and I had some encoding errors (utf-8 handle 2.7 versus 3.4).

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

I finally create a virtualenv on my docroot, where I installed django (1.8.2).

And here is the lines you have to add (for me apache) :

WSGIScriptAlias / /var/www/cal/calendar_month/wsgi.py
WsgiPythonPath /var/www/cal
WSGIDaemonProcess calendar_month python-path=/var/www/cal:/var/www/cal/local/lib/python3.4

The line WSGIDaemonProcess allows you to specifiy your venv path (as @albar suggest, and in @gbs answer link).

Whatever, thanks you for help

Hope mine will help too.

2👍

Since you’re deploying with Apache, you will need to install a python3 version of mod_wsgi. On Ubuntu and Debian-based distributions this might be as simple as:

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

As you’re using a virtualenv, you will also need to point your httpd.conf to its directory in order to use it. See https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/ for more info.

👤gbs

1👍

In your apache configuration file, you should have a python path:

WSGIDaemonProcess myapp python-path=/path/to/myapp:/usr/local/lib/python3.4/dist-packages
                                                                  ^^^^^^^^^
👤albar

Leave a comment