【问题标题】:Python error in Eclipse: SyntaxError: future feature print_function is not definedEclipse 中的 Python 错误:SyntaxError:未定义未来功能 print_function
【发布时间】:2014-07-21 09:35:06
【问题描述】:

我正在尝试让 python 在 Eclipse 中与我一起工作。我确实下载了 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

我该如何解决?

【问题讨论】:

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


    【解决方案1】:

    只有 python 2.7+ 有 print_function future import。

    如果你升级到 Jython 2.7 Beta 2 我敢打赌这个问题会得到解决

    【讨论】:

    猜你喜欢
    • 2020-09-22
    • 2021-03-05
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 1970-01-01
    • 2018-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多