Найти - Пользователи
Полная версия: процесс wsgi использует не ту версию питона
Начало » Python для экспертов » процесс wsgi использует не ту версию питона
1
kosolapovdg
Добрый день. Есть старый, но работающий сервер под управлением Ubuntu 10.04. На нем работает пара сайтов на python 2.6
Есть задача запустить на этом сервере сайт, работающий на python 3.3
Сам интерпретатор установил из пакетов (подключил репозиторий)
Проблема в том, что сам wsgi процесс использует python 2.6, из-за разных версий сайт не работает.

Ошибка:
[Mon Sep 29 10:58:10 2014] [error] [client 192.168.1.3]  SyntaxError: invalid syntax
[Mon Sep 29 10:58:10 2014] [error] Exception KeyError: KeyError(-1216624896,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] mod_wsgi (pid=28057): Exception occurred processing WSGI script '/home/theatre/theatre_/theatre/wsgi.py'.
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] Traceback (most recent call last):
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/core/handlers/wsgi.py", line 187, in __call__
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] self.load_middleware()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/core/handlers/base.py", line 47, in load_middleware
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] mw_instance = mw_class()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/middleware/locale.py", line 24, in __init__
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] for url_pattern in get_resolver(None).url_patterns:
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/core/urlresolvers.py", line 365, in url_patterns
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/core/urlresolvers.py", line 360, in urlconf_module
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] self._urlconf_module = import_module(self.urlconf_name)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/utils/importlib.py", line 40, in import_module
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] __import__(name)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/theatre/urls.py", line 5, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] admin.autodiscover()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/contrib/admin/__init__.py", line 29, in autodiscover
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] import_module('%s.admin' % app)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/utils/importlib.py", line 40, in import_module
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] __import__(name)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/contrib/auth/admin.py", line 182, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] admin.site.register(Group, GroupAdmin)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/contrib/admin/sites.py", line 92, in register
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] admin_class.validate(model)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/contrib/admin/options.py", line 105, in validate
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] validator = cls.validator_class()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/contrib/admin/validation.py", line 20, in __init__
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] models.get_apps()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/db/models/loading.py", line 139, in get_apps
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] self._populate()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/db/models/loading.py", line 75, in _populate
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] self.load_app(app_name, True)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/db/models/loading.py", line 99, in load_app
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] models = import_module('%s.models' % app_name)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/utils/importlib.py", line 40, in import_module
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] __import__(name)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/models.py", line 9, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] dt_settings.patch_all()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/settings.py", line 214, in patch_all
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] patch_middleware_classes()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/settings.py", line 193, in patch_middleware_classes
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] if not is_toolbar_middleware_installed():
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/settings.py", line 175, in is_toolbar_middleware_installed
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] for middleware in settings.MIDDLEWARE_CLASSES)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/settings.py", line 175, in <genexpr>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] for middleware in settings.MIDDLEWARE_CLASSES)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/settings.py", line 162, in is_toolbar_middleware
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] from debug_toolbar.middleware import DebugToolbarMiddleware
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/middleware.py", line 14, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] from debug_toolbar.toolbar import DebugToolbar
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/toolbar.py", line 163, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] urlpatterns = DebugToolbar.get_urls()
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/toolbar.py", line 157, in get_urls
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] for panel_class in cls.get_panel_classes():
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/toolbar.py", line 131, in get_panel_classes
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] mod = import_module(panel_module)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/Django-1.6.7-py3.3.egg/django/utils/importlib.py", line 40, in import_module
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] __import__(name)
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/panels/sql/__init__.py", line 1, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] from debug_toolbar.panels.sql.panel import SQLPanel # noqa
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/panels/sql/panel.py", line 12, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] from debug_toolbar.panels.sql.forms import SQLSelectForm
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/panels/sql/forms.py", line 13, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] from debug_toolbar.panels.sql.utils import reformat_sql
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/django_debug_toolbar-1.2.1-py3.3.egg/debug_toolbar/panels/sql/utils.py", line 7, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] import sqlparse
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/sqlparse-0.1.11-py3.3.egg/sqlparse/__init__.py", line 13, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/sqlparse-0.1.11-py3.3.egg/sqlparse/engine/__init__.py", line 8, in <module>
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] File "/home/theatre/theatre_/lib/python3.3/site-packages/sqlparse-0.1.11-py3.3.egg/sqlparse/lexer.py", line 156
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] class Lexer(object, metaclass=LexerMeta):
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] ^
[Mon Sep 29 10:58:13 2014] [error] [client 192.168.1.3] SyntaxError: invalid syntax
[Mon Sep 29 10:58:13 2014] [error] Exception KeyError: KeyError(-1216624896,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored

Конфиг виртуального хоста:
<VirtualHost *:80>
        ServerAdmin self@dicos.ru
        ServerName theatre.dicos.ru
        Alias /media/ /home/db_gnokdc/www/project/db_gnokdc/media/
        Alias /admin_media/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
        <Directory /home/theatre/theatre_/theatre>
                <Files wsgi.py>
                        Order allow,deny
                        allow from all
                </Files>
        </Directory>
        WSGIScriptAlias / /home/theatre/theatre_/theatre/wsgi.py
        WSGIDaemonProcess theatre processes=1 maximum-requests=1 threads=1 user=theatre umask=000 python-path=/home/theatre/theatre_/lib/python3.3/site-packages
        WSGIProcessGroup theatre
        ErrorLog /home/theatre/error.log
        LogLevel warn
        CustomLog /home/theatre/access.log combined
</VirtualHost>

код wsgi.py:
"""
WSGI config for theatre project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
"""
import os
import sys
# activate venv
activate_this = '/home/theatre/theatre_/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
# insert project path to sys path
path = '/home/theatre/theatre_/theatre'
if path not in sys.path:
    sys.path.insert(0, path)
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
kosolapovdg
Вопрос закрыт, обошелся вот этой штукой: https://pypi.python.org/pypi/mod_wsgi
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB