Anaconda + Apache + mod_wsgi + Ubuntu

Je gère un serveur avec Ubuntu et Apache. J’essaie maintenant de faire fonctionner Anaconda avec mod_wsgi, mais je n’arrive pas à le faire fonctionner.

Tout d’abord. Cela fonctionne si j’utilise mod_wsgi-express. En suivant les instructions sur https://anaconda.org/pypi/mod_wsgi dans la section Installation dans Python, je peux le faire fonctionner en définissant d’abord PYTHONHOME=/opt/anaconda et ensuite /opt/anaconda3/bin/mod_wsgi-express start-server .

Je veux utiliser Apache donc je charge le module mod_wsgi d’anaconda dans apache. Et puis j’ai un VirtualHost ressemblant à ceci:

 WSGIPythonHome /opt/anaconda3 WSGIPythonPath /opt/anaconda3/lib/python3.6/site-packages:/path/to/application  ServerName example.com WSGIDaemonProcess example python-home=/opt/anaconda3 python-path=path/to/application:/opt/anaconda3/lib/python3.6/site-packages WSGIProcessGroup example WSGIScriptAlias / /path/to/application/wsgi.py  Require all granted    Require all granted    

Maintenant au problème. Je reçois cette erreur dans mon journal des erreurs apache. J’ai la même erreur si je ne spécifie pas PYTHONHOME=/opt/anaconda avec mod_wsgi_express.

 [Wed Mar 01 09:31:17.159233 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19356 (gen 0/slot 1) started [Wed Mar 01 09:31:17.159638 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19357 (gen 0/slot 2) started [Wed Mar 01 09:31:17.160049 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19358 (gen 0/slot 6) started [Wed Mar 01 09:31:17.160467 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19359 (gen 0/slot 7) started [Wed Mar 01 09:31:17.160967 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19360 (gen 0/slot 8) started [Wed Mar 01 09:31:17.161421 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19361 (gen 0/slot 9) started [Wed Mar 01 09:31:17.161877 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19362 (gen 0/slot 10) started [Wed Mar 01 09:31:17.162345 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19363 (gen 0/slot 11) started [Wed Mar 01 09:31:17.162792 2017] [wsgi:info] [pid 19361] mod_wsgi (pid=19361): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.162817 2017] [wsgi:info] [pid 19361] mod_wsgi (pid=19361): Initializing Python. [Wed Mar 01 09:31:17.166761 2017] [wsgi:info] [pid 19362] mod_wsgi (pid=19362): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.166806 2017] [wsgi:info] [pid 19362] mod_wsgi (pid=19362): Initializing Python. [Wed Mar 01 09:31:17.170927 2017] [wsgi:info] [pid 19360] mod_wsgi (pid=19360): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.170967 2017] [wsgi:info] [pid 19360] mod_wsgi (pid=19360): Initializing Python. [Wed Mar 01 09:31:17.174897 2017] [wsgi:info] [pid 19359] mod_wsgi (pid=19359): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.174921 2017] [wsgi:info] [pid 19359] mod_wsgi (pid=19359): Initializing Python. [Wed Mar 01 09:31:17.178746 2017] [wsgi:info] [pid 19363] mod_wsgi (pid=19363): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.178769 2017] [wsgi:info] [pid 19363] mod_wsgi (pid=19363): Initializing Python. [Wed Mar 01 09:31:17.182570 2017] [core:notice] [pid 16941] AH00052: child pid 19317 exit signal Aborted (6) [Wed Mar 01 09:31:17.182582 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19317 (gen 0/slot 0) exited [Wed Mar 01 09:31:17.182594 2017] [core:notice] [pid 16941] AH00052: child pid 19318 exit signal Aborted (6) [Wed Mar 01 09:31:17.182597 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19318 (gen 0/slot 3) exited [Wed Mar 01 09:31:17.182605 2017] [core:notice] [pid 16941] AH00052: child pid 19319 exit signal Aborted (6) [Wed Mar 01 09:31:17.182608 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19319 (gen 0/slot 4) exited [Wed Mar 01 09:31:17.182615 2017] [core:notice] [pid 16941] AH00052: child pid 19320 exit signal Aborted (6) [Wed Mar 01 09:31:17.182618 2017] [core:trace4] [pid 16941] mpm_common.c(530): mpm child 19320 (gen 0/slot 5) exited [Wed Mar 01 09:31:17.182636 2017] [wsgi:info] [pid 16941] mod_wsgi (pid=19321): Process 'store-test' has died but server is being stopped, deregister it. [Wed Mar 01 09:31:17.182646 2017] [wsgi:info] [pid 16941] mod_wsgi (pid=19321): Process 'store-test' has been deregistered and will no longer be monitored. [Wed Mar 01 09:31:17.182934 2017] [wsgi:info] [pid 19358] mod_wsgi (pid=19358): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.182954 2017] [wsgi:info] [pid 19358] mod_wsgi (pid=19358): Initializing Python. [Wed Mar 01 09:31:17.186756 2017] [wsgi:info] [pid 19357] mod_wsgi (pid=19357): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.186781 2017] [wsgi:info] [pid 19357] mod_wsgi (pid=19357): Initializing Python. [Wed Mar 01 09:31:17.190807 2017] [wsgi:info] [pid 19356] mod_wsgi (pid=19356): Python home /opt/anaconda3. [Wed Mar 01 09:31:17.190840 2017] [wsgi:info] [pid 19356] mod_wsgi (pid=19356): Initializing Python. Could not find platform independent libraries  Could not find platform dependent libraries  Consider setting $PYTHONHOME to [:] Fatal Python error: Py_Initialize: Unable to get the locale encoding ModuleNotFoundError: No module named 'encodings' Current thread 0x00007f4ad9333780 (most recent call first): 

Quelqu’un sait ce que je peux faire pour que ça marche?

Vous ne pouvez utiliser aucun package système pour mod_wsgi si vous souhaitez utiliser Anaconda Python. La première étape consiste donc à désinstaller tout package mod_wsgi du système.

Puis utilisez pip install mod_wsgi pour installer mod_wsgi-express dans votre installation ou environnement virtuel Anaconda Python.

Puis lancez:

 mod_wsgi-express module-config 

Prenez-en le résultat et placez-le dans votre fichier de configuration Apache pour charger mod_wsgi.

Ajoutez ensuite à Apache la configuration de mod_wsgi pour votre application WSGI spécifique.

Affichez la configuration que vous utilisez après l’avoir fait si vous rencontrez des problèmes.