Python error in Eclipse: SyntaxError: future feature print_function is not defined

4.2k Views Asked by At

I'm trying to get python works in Eclipse with me. I did download Pydev and wrote a small python code.

my python version is: Python 2.7.6 on my Mac OS X 10.9.2

the error I'm receiving now is(BTW I'm getting this error with Jython 2.5.4rc1 and Python interpreters):

Traceback (most recent call last):
  File "/Users/ha/EclipseProjects/PythonNLTK/Code.py", line 11, in <module>
    import nltk
  File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 99, in <module>
    from collocations import *
  File "/Library/Python/2.7/site-packages/nltk/collocations.py", line 38, in <module>
    from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
  File "/Library/Python/2.7/site-packages/nltk/metrics/__init__.py", line 23, in <module>
    from nltk.metrics.segmentation    import windowdiff, ghd, pk
  File "/Library/Python/2.7/site-packages/nltk/metrics/segmentation.py", line 45, in <module>
    import numpy
  File "/Library/Python/2.7/site-packages/nltk/metrics/segmentation.py", line 45, in <module>
    import numpy
  File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 107
SyntaxError: future feature print_function is not defined

How can I solve it?

1

There are 1 best solutions below

1
On

Only python 2.7+ has the print_function future import.

If you upgrade to Jython 2.7 Beta 2 I bet this problem will be solved