diff --git a/nltk_tgrep/tests/test_tgrep.py b/nltk_tgrep/tests/test_tgrep.py index a5d0d13..055976b 100644 --- a/nltk_tgrep/tests/test_tgrep.py +++ b/nltk_tgrep/tests/test_tgrep.py @@ -7,8 +7,12 @@ (c) 16 March, 2013 Will Roberts ''' -from __future__ import unicode_literals -from builtins import range +from __future__ import print_function, unicode_literals +try: + from builtins import range +except ImportError: + print('Warning: nltk_tgrep may not work correctly on Python 2.* without the ') + print('`future` package installed.') from nltk.tree import ParentedTree from .. import tgrep import unittest diff --git a/nltk_tgrep/tgrep.py b/nltk_tgrep/tgrep.py index ef09e56..40639fe 100644 --- a/nltk_tgrep/tgrep.py +++ b/nltk_tgrep/tgrep.py @@ -60,11 +60,19 @@ macro definitions to `m` and initialises `l` to an empty dictionary. ''' -from __future__ import unicode_literals -from builtins import bytes, range, str +from __future__ import print_function, unicode_literals +try: + from builtins import bytes, range, str +except ImportError: + print('Warning: nltk_tgrep may not work correctly on Python 2.* without the') + print('`future` package installed.') import functools import nltk.tree -import pyparsing +try: + import pyparsing +except ImportError: + print('Warning: nltk_tgrep will not work without the `pyparsing` package') + print('installed.') import re class TgrepException(Exception):