From 66bfe1797b51b53d9df10759af9ba42ab38b4100 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 20 Nov 2014 22:58:44 +0530 Subject: [PATCH] Do not use the pygments based highlighter if the user does not have pygments (will happen on some linux distros and for people running from source who dont update the binary) --- src/calibre/gui2/tweak_book/editor/text.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index 8d2ea3ac7b..57c41ad1f3 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -40,8 +40,11 @@ def get_highlighter(syntax): if ans is SyntaxHighlighter: # Load these highlighters only on demand if syntax == 'python': - from calibre.gui2.tweak_book.editor.syntax.python import PythonHighlighter - ans = PythonHighlighter + try: + from calibre.gui2.tweak_book.editor.syntax.python import PythonHighlighter + ans = PythonHighlighter + except ImportError: + pass # For people running from source return ans _dff = None