Weblate: ImportError raised when trying to load 'weblate.permissions.templatetags.permissions': cannot import name get_anonymous

Created on 7 Jun 2018  路  2Comments  路  Source: WeblateOrg/weblate

Hi Guys,

we're running weblate 2.20 on an ubuntu 16.04 VM and trying to upgrade to weblate 3.0.
I've followed the upgrade guide as suggested and the upgrade process went well.
But the webinterface is not accessible after the upgrade and I get the following error message:

Exception Type:     InvalidTemplateLibrary
Exception Value:    Invalid template library specified. ImportError raised when trying to load 'weblate.permissions.templatetags.permissions': cannot import name get_anonymous
Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/backends/django.py in get_package_libraries, line 130

When I comment out the line 'weblate.permissions', from the INSTALLED_APPS section in the settings.py file it's working properly. But I don't think that this is an acceptable solution ...

Traceback

Environment:


Request Method: GET
Request URL: http://192.168.105.197/

Django Version: 1.11.13
Python Version: 2.7.12
Installed Applications:
(u'django.contrib.auth',
 u'django.contrib.contenttypes',
 u'django.contrib.sessions',
 u'django.contrib.sites',
 u'django.contrib.messages',
 u'django.contrib.staticfiles',
 u'django.contrib.admin.apps.SimpleAdminConfig',
 u'django.contrib.admindocs',
 u'django.contrib.sitemaps',
 u'social_django',
 u'crispy_forms',
 u'compressor',
 u'rest_framework',
 u'rest_framework.authtoken',
 u'weblate.addons',
 u'weblate.auth',
 u'weblate.checks',
 u'weblate.formats',
 u'weblate.machinery',
 u'weblate.trans',
 u'weblate.lang',
 u'weblate.langdata',
 u'weblate.memory',
 u'weblate.permissions',
 u'weblate.screenshots',
 u'weblate.accounts',
 u'weblate.utils',
 u'weblate.vcs',
 u'weblate.wladmin',
 u'weblate')
Installed Middleware:
[u'django.middleware.security.SecurityMiddleware',
 u'django.contrib.sessions.middleware.SessionMiddleware',
 u'django.middleware.common.CommonMiddleware',
 u'django.middleware.locale.LocaleMiddleware',
 u'django.middleware.csrf.CsrfViewMiddleware',
 u'weblate.accounts.middleware.AuthenticationMiddleware',
 u'django.contrib.messages.middleware.MessageMiddleware',
 u'django.middleware.clickjacking.XFrameOptionsMiddleware',
 u'social_django.middleware.SocialAuthExceptionMiddleware',
 u'weblate.accounts.middleware.RequireLoginMiddleware',
 u'weblate.middleware.SecurityMiddleware',
 u'weblate.wladmin.middleware.ConfigurationErrorsMiddleware']



Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/opt/weblate/weblate/trans/views/basic.py" in home
  245.             'active_tab_slug': active_tab_slug,

File "/opt/weblate/weblate/trans/util.py" in render
  218.     return django_render(request, template, context, status=status)

File "/usr/local/lib/python2.7/dist-packages/django/shortcuts.py" in render
  30.     content = loader.render_to_string(template_name, context, request, using=using)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in render_to_string
  67.         template = get_template(template_name, using=using)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in get_template
  18.     engines = _engine_list(using)

File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py" in _engine_list
  72.     return engines.all() if using is None else [engines[using]]

File "/usr/local/lib/python2.7/dist-packages/django/template/utils.py" in all
  89.         return [self[alias] for alias in self]

File "/usr/local/lib/python2.7/dist-packages/django/template/utils.py" in __getitem__
  80.             engine = engine_cls(params)

File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in __init__
  30.         options['libraries'] = self.get_templatetag_libraries(libraries)

File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in get_templatetag_libraries
  48.         libraries = get_installed_libraries()

File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in get_installed_libraries
  113.             for name in get_package_libraries(pkg):

File "/usr/local/lib/python2.7/dist-packages/django/template/backends/django.py" in get_package_libraries
  130.                 "trying to load '%s': %s" % (entry[1], e)

Exception Type: InvalidTemplateLibrary at /
Exception Value: Invalid template library specified. ImportError raised when trying to load 'weblate.permissions.templatetags.permissions': cannot import name get_anonymous

Server configuration

root@weblate_30_test:/opt/weblate# ./manage.py list_versions
 * Weblate weblate-3.0
 * Python 2.7.12
 * Django 1.11.13
 * six 1.11.0
 * social-auth-core 1.4.0
 * social-auth-app-django 1.2.0
 * django-appconf 1.0.2
 * Translate Toolkit 2.3.0
 * Whoosh 2.7.2
 * defusedxml 0.4.1
 * Git 2.7.4
 * Pillow (PIL) 1.1.7
 * dateutil 2.4.2
 * lxml 4.0.0
 * django-crispy-forms 1.6.1
 * compressor 2.1
 * djangorestframework 3.8.2
 * user-agents 1.1.0
 * pytz 2016.3
 * pyuca N/A
 * pyLibravatar N/A
 * PyYAML 3.12
 * Mercurial 3.7.3
 * Database backends: django.db.backends.mysql
 * Cache backends: default:LocMemCache
question

Most helpful comment

It seems you are using old code copy there. This should be fixed by removing cached Python compiled files:

find /opt/weblate/weblate -name '*.pyc' -delete

All 2 comments

It seems you are using old code copy there. This should be fixed by removing cached Python compiled files:

find /opt/weblate/weblate -name '*.pyc' -delete

Thank you for this quick answer.

It solved the problem and it looks like it's working well ;)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

BoFFire picture BoFFire  路  4Comments

nblock picture nblock  路  3Comments

reloxx13 picture reloxx13  路  3Comments

WTBenjamin picture WTBenjamin  路  4Comments

mlaggner picture mlaggner  路  3Comments