Installieren Sie mod_wsgi auf Ubuntu mit Python 3.6, Apache 2.4 und Django 1.11

1982
JxAxMxIxN

Wie bekomme ich mod_wsgi für Apache2, das für Python 3.6.1 kompiliert wurde?

(oder eine zukünftige Python-Version)

Ich verwende eine virtuelle Umgebung von Python 3.6.1 mit Django 1.11, und alles funktioniert gemäß dem Apache-Fehlerprotokoll, mit der Ausnahme, dass mod_wsgi für Apache 2.4 für Python / 3.5.1 + kompiliert wurde und Python / 3.5.2 verwendet, also mein Python 3.6 .1-Code schlägt fehl, weil ich neue Funktionen verwende, die in 3.5.2 nicht verfügbar sind

Alle anderen Konfigurationen und Installationen, die an der Einrichtung meines Systems beteiligt sind, scheinen in Ordnung zu sein (im Dämonmodus ausgeführt), obwohl mod_wsgi nicht die virtuelle Umgebung von Python 3.6.1 zu verwenden scheint (obwohl er versucht, sie für Django zu verwenden zum Fehlerprotokoll) ...

Ich habe verwendet: sudo apt-get install libapache2-mod-wsgi-py3 um mod_wsgi für Apache 2.4 zu installieren

Ich habe verwendet: ./configure --with-python=/usr/local/bin/python3.6 und makemit make installum mod_wsgi für Python 3.6 zu installieren

Ich muss etwas falsch machen - bitte korrigieren Sie mich!

Hier ist mein Apache-Fehlerprotokoll (etwas bereinigt) - und ich weiß, dass es in der f "" - Zeile fehlschlägt (Python 3.6-Funktion nicht in 3.5).

[wsgi:warn] mod_wsgi: Compiled for Python/3.5.1+. [wsgi:warn] mod_wsgi: Runtime using Python/3.5.2. [wsgi:warn] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations [wsgi:warn] AH00094: Command line: '/usr/sbin/apache2' [wsgi:error] mod_wsgi (pid=12963): Target WSGI script '/home/jamin/www/dev.tir.com/tir/tir/wsgi.py' cannot be loaded as Python module. [wsgi:error] mod_wsgi (pid=12963): Exception occurred processing WSGI script '/home/jamin/www/dev.tir.com/tir/tir/wsgi.py'. [wsgi:error] Traceback (most recent call last): [wsgi:error] File "/home/jamin/www/dev.tir.com/tir/tir/wsgi.py", line 21, in <module> [wsgi:error] application = get_wsgi_application() [wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application [wsgi:error] django.setup(set_prefix=False) [wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/__init__.py", line 27, in setup [wsgi:error] apps.populate(settings.INSTALLED_APPS) [wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/apps/registry.py", line 116, in populate [wsgi:error] app_config.ready() [wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/contrib/admin/apps.py", line 23, in ready [wsgi:error] self.module.autodiscover() [wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover [wsgi:error] autodiscover_modules('admin', register_to=site) [wsgi:error] File "/home/jamin/www/dev.tir.com/py361ve/lib/python3.6/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules [wsgi:error] import_module('%s.%s' % (app_config.name, module_to_search)) [wsgi:error] File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module [wsgi:error] return _bootstrap._gcd_import(name[level:], package, level) [wsgi:error] File "<frozen importlib._bootstrap>", line 986, in _gcd_import [wsgi:error] File "<frozen importlib._bootstrap>", line 969, in _find_and_load [wsgi:error] File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked [wsgi:error] File "<frozen importlib._bootstrap>", line 673, in _load_unlocked [wsgi:error] File "<frozen importlib._bootstrap_external>", line 665, in exec_module [wsgi:error] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed [wsgi:error] File "/home/jamin/www/dev.tir.com/tir/company/admin.py", line 13, in <module> [wsgi:error] from .forms import AdminInteractionForm [wsgi:error] File "/home/jamin/www/dev.tir.com/tir/company/forms.py", line 87 [wsgi:error] resp = f"Hi, you'll need to login to send any more suggestions. \\ [wsgi:error] \\n\\nFirst Time? Check your email/spam for login instructions from us." [wsgi:error]  [wsgi:error] ^ [wsgi:error] SyntaxError: invalid syntax 

* auch tir.com ist die Abkürzung für meine aktuelle Website - ich habe mit dieser Domain nichts zu tun

2
Hast du es jemals herausgefunden? MadPhysicist vor 6 Jahren 0

1 Antwort auf die Frage

0
Anton Khodak

Sie müssen die aptVersion deinstallieren, die Installation in der zu verwendenden Umgebung durchführen und dann die installierte Version mod_wsgimit Apache pipverknüpfen mod_wsgi. Hier ist die Antwort, die für mich funktioniert hat: https://stackoverflow.com/a/30682386/4454597