Kallithea issues archive

Issue #182: Kallithea can't support Python-2.7.11

Reported by: bitworld
State: resolved
Created on: 2015-12-26 14:45
Updated on: 2017-06-13 19:23

Description

Kallithea can't work well with Python-2.7.11, that is, the http://127.0.0.1:5000/_admin/settings page can't be opened.

The reason is https://github.com/celery/kombu/issues/545. See also: http://stackoverflow.com/questions/34198538/cannot-import-name-uuid-generate-random-in-heroku-django

Attachments

Comments

Comment by Mads Kiilerich, on 2015-12-26 15:37

That seems like an unfortunate change in Python that caused a problem for Kombu. How does that influence Kallithea and what can be done in Kallithea to mitigate the problem? It seems like you just have to upgrade kombu to a version that works with your Python?

Comment by Michaƫl BROUTIN, on 2015-12-31 15:04

I also ran into this problem, and I first tried upgrading Kombu to the latest version, but doing so prevents Kallithea to run (since Kombu version is expected to be <2.0.0 and the fix is in 3.0.20). Downgrading to Python-2.7.10 fixed the problem for me.

Comment by Mads Kiilerich, on 2016-01-01 17:43

Please test if this patch makes it work for you with 2.7.11:

--- a/kallithea/lib/celerypylons/commands.py
+++ b/kallithea/lib/celerypylons/commands.py
@@ -1,4 +1,9 @@
 # -*- coding: utf-8 -*-

+# Hack for making kombu==1.5.1 compatible with Python 2.7.11 with https://hg.python.org/releases/2.7.11/rev/24bdc4940e81
+import uuid
+if not hasattr(uuid, '_uuid_generate_random'):
+    uuid._uuid_generate_random = None
+
 import kallithea
 from kallithea.lib.utils import BasePasterCommand, Command, load_rcextensions

Comment by bitworld, on 2016-01-02 04:33

I have upgraded the Kombu and the Celery : pip install --upgrade Kombu celery

and patched the Kallithea. It does not works yet.

Here is my error log:

Error - <type 'exceptions.ImportError'>: cannot import name _uuid_generate_rando
m
URL: http://127.0.0.1:5000/_admin/settings
sys.path: [
    'D:\\Kallithea\\Sources',
    'D:\\Kallithea\\Env\\Scripts',
    'd:\\kallithea\\sources',
    'D:\\Kallithea\\Env\\lib\\site-packages\\mercurial-3.6.3-py2.7-win32.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\dulwich-0.9.9-py2.7-win32.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\routes-1.13-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\urlobject-2.3.4-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\mock-1.3.0-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\docutils-0.11-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\markdown-2.2.1-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\python_dateutil-1.5-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\babel-1.3-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\celery-2.2.10-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\whoosh-2.5.7-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\pygments-2.0.2-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\mako-1.0.0-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\sqlalchemy-0.7.10-py2.7-win32.egg',

    'D:\\Kallithea\\Env\\lib\\site-packages\\formencode-1.2.6-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\webhelpers-1.3-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\beaker-1.6.4-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\pylons-1.0.2-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\webtest-1.4.3-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\webob-1.1.1-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\waitress-0.8.8-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\repoze.lru-0.6-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\funcsigs-0.4-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\pbr-1.8.1-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\pyparsing-1.5.7-py2.7-win32.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\kombu-1.5.1-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\markupsafe-0.23-py2.7-win32.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\tempita-0.5.3.dev0-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\weberror-0.11-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\nose-1.3.7-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\decorator-4.0.6-py2.7.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\simplejson-3.8.1-py2.7-win32.egg',
    'D:\\Kallithea\\Env\\lib\\site-packages\\amqplib-1.0.2-py2.7.egg',
    'd:\\kallithea\\sources\\.eggs\\six-1.10.0-py2.7.egg',
    'd:\\kallithea\\sources\\.eggs\\pastescript-2.0.2-py2.7.egg',
    'd:\\kallithea\\sources\\.eggs\\pastedeploy-1.5.2-py2.7.egg',
    'd:\\kallithea\\sources\\.eggs\\paste-2.0.2-py2.7.egg',
    'C:\\Windows\\system32\\python27.zip',
    'D:\\Kallithea\\Env\\DLLs',
    'D:\\Kallithea\\Env\\lib',
    'D:\\Kallithea\\Env\\lib\\plat-win',
    'D:\\Kallithea\\Env\\lib\\lib-tk',
    'D:\\Kallithea\\Env\\Scripts',
    'c:\\python27\\Lib',
    'c:\\python27\\DLLs',
    'c:\\python27\\Lib\\lib-tk',
    'D:\\Kallithea\\Env',
    'D:\\Kallithea\\Env\\lib\\site-packages']
File 'D:\\Kallithea\\Env\\lib\\site-packages\\weberror-0.11-py2.7.egg\\weberror\
\errormiddleware.py', line 171 in __call__
  app_iter = self.application(environ, sr_checker)
File 'D:\\Kallithea\\Sources\\kallithea\\lib\\middleware\\sessionmiddleware.py',
 line 62 in __call__
  return self.wrap_app(environ, session_start_response)
File 'D:\\Kallithea\\Env\\lib\\site-packages\\routes-1.13-py2.7.egg\\routes\\mid
dleware.py', line 131 in __call__
  response = self.app(environ, start_response)
File 'D:\\Kallithea\\Env\\lib\\site-packages\\pylons-1.0.2-py2.7.egg\\pylons\\ws
giapp.py', line 102 in __call__
  controller = self.resolve(environ, start_response)
File 'D:\\Kallithea\\Env\\lib\\site-packages\\pylons-1.0.2-py2.7.egg\\pylons\\ws
giapp.py', line 231 in resolve
  return self.find_controller(controller)
File 'D:\\Kallithea\\Env\\lib\\site-packages\\pylons-1.0.2-py2.7.egg\\pylons\\ws
giapp.py', line 269 in find_controller
  __import__(full_module_name)
File 'D:\\Kallithea\\Sources\\kallithea\\controllers\\admin\\settings.py', line
40 in <module>
  from kallithea.lib.celerylib import tasks, run_task
File 'D:\\Kallithea\\Sources\\kallithea\\lib\\celerylib\\tasks.py', line 29 in <
module>
  from celery.decorators import task
File 'D:\\Kallithea\\Env\\lib\\site-packages\\celery-2.2.10-py2.7.egg\\celery\\d
ecorators.py', line 17 in <module>
  from celery import task as _task
File 'D:\\Kallithea\\Env\\lib\\site-packages\\celery-2.2.10-py2.7.egg\\celery\\t
ask\\__init__.py', line 4 in <module>
  from celery.app import app_or_default
File 'D:\\Kallithea\\Env\\lib\\site-packages\\celery-2.2.10-py2.7.egg\\celery\\a
pp\\__init__.py', line 16 in <module>
  from kombu.utils import cached_property
File 'D:\\Kallithea\\Env\\lib\\site-packages\\kombu-1.5.1-py2.7.egg\\kombu\\util
s\\__init__.py', line 14 in <module>
  from uuid import UUID, uuid4 as _uuid4, _uuid_generate_random
ImportError: cannot import name _uuid_generate_random

Comment by Mads Kiilerich, on 2016-01-02 21:45

Unfortunately celery isn't encapsulated as much as it should have been ...

Can you try placing the same snippet in kallithea/__init__.py ? That seems to work for the test cases I have seen.

Comment by bitworld, on 2016-01-03 02:17

It works now. Thanks.

Comment by Thomas De Schampheleire, on 2017-06-13 19:23

Fix applied as 2189802db18a and later modified after other changes with 940a48e28a03.