Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#25158 closed Bug (invalid)

InvalidTemplateLibrary when using django_extensions

Reported by: James Addison Owned by: nobody
Component: Uncategorized Version: dev
Severity: Release blocker Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


Trying to use django_extensions version 1.5.5 with Django master branch gives this traceback:


Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.9.dev20150721153804
Python Version: 3.4.3
Installed Applications:
Installed Middleware:


File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/" in __getitem__
  86.             return self._engines[alias]

During handling of the above exception ('django'), another exception occurred:

File "/Users/jaddison/.virtualenvs/django19test/lib/python3.4/site-packages/django_extensions/templatetags/" in <module>
  41.     from pygments import highlight as pyghighlight

During handling of the above exception (No module named 'pygments'), another exception occurred:

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/" in get_package_libraries
  144.             module = import_module(entry[1])

File "/Users/jaddison/.virtualenvs/django19test/lib/python3.4/importlib/" in import_module
  109.     return _bootstrap._gcd_import(name[level:], package, level)

File "/Users/jaddison/.virtualenvs/django19test/lib/python3.4/site-packages/django_extensions/templatetags/" in <module>
  45.     raise ImportError("Please install 'pygments' library to use highlighting.")

During handling of the above exception (Please install 'pygments' library to use highlighting.), another exception occurred:

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/core/handlers/" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/jaddison/projects/django19test/testviews/" in testview
  5.     return render(request, template)

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/" in render
  67.             template_name, context, request=request, using=using)

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/" in render_to_string
  91.             template = get_template(template_name, using=using)

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/" in get_template
  21.     engines = _engine_list(using)

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/" in _engine_list
  139.     return engines.all() if using is None else [engines[using]]

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/" in all
  110.         return [self[alias] for alias in self]

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/" in <listcomp>
  110.         return [self[alias] for alias in self]

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/" in __getitem__
  101.             engine = engine_cls(params)

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/" in __init__
  31.         options['libraries'] = self.get_templatetag_libraries(libraries)

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/" in get_templatetag_libraries
  49.         libraries = get_installed_libraries()

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/" in get_installed_libraries
  131.             for name in get_package_libraries(pkg):

File "/Users/jaddison/.virtualenvs/django19test/src/django/django/template/backends/" in get_package_libraries
  148.                 "trying to load '%s': %s" % (entry[1], e)

Exception Type: InvalidTemplateLibrary at /
Exception Value: Invalid template library specified. ImportError raised when trying to load 'django_extensions.templatetags.highlighting': Please install 'pygments' library to use highlighting.

I'm not positive, but it looks like it will always blow up when a template tag 'library' is encountered that has missing Python dependencies - even if you don't use that library.

Change History (4)

comment:1 Changed 7 years ago by James Addison

Followup - I noticed this when trying to use django-pipeline version 1.5.2 as well.

comment:2 Changed 7 years ago by Tim Graham

Resolution: invalid
Status: newclosed

I guess it's related to this backwards incompatible change:

You should raise the issue with the library authors so they can update their packages or reopen this issue with more details about why this is a bug in Django. Thanks!

comment:3 Changed 7 years ago by James Addison

Ah, I missed that! I've raised issues in both django-extensions and django-pipeline - however, I do have to wonder how many packages will 'break' Django due to this, preventing many people from upgrading.

I assume that a break in the Django ecosystem is worth this change. :)

comment:4 Changed 7 years ago by Aymeric Augustin

Well, if you have a non-functional library, I find it preferrable to crash at startup so you can notice and fix the issue, than randomly on pages that use the library.

Note: See TracTickets for help on using tickets.
Back to Top