Eclipse中的Python错误:SyntaxError:未定义future feature print_function

时间:2014-05-31 21:36:42

标签: python eclipse python-2.7 python-3.x jython-2.5

我正在尝试让Eclipse中的python工作。我确实下载了Pydev并编写了一个小的python代码。

我的python版本是:Python 2.7.6 在我的Mac OS X 10.9.2上

我现在收到的错误是(顺便说一句,我在使用Jython 2.5.4rc1和Python解释器时遇到此错误):

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

我该如何解决?

1 个答案:

答案 0 :(得分:1)

只有python 2.7+具有print_function的未来导入。

如果您升级到 Jython 2.7 Beta 2 ,我打赌这个问题将会解决