2

入力すると

import nltk

Python インタプリタでは、これが表示されます --

>>> import nltk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/nltk/__init__.py", line 105, in <module>
    from collocations import *
  File "/usr/local/lib/python2.7/dist-packages/nltk/collocations.py", line 38, in <module>
    from nltk.metrics import ContingencyMeasures, BigramAssocMeasures, TrigramAssocMeasures
  File "/usr/local/lib/python2.7/dist-packages/nltk/metrics/__init__.py", line 16, in <module>
    from nltk.metrics.scores import          (accuracy, precision, recall, f_measure,
  File "/usr/local/lib/python2.7/dist-packages/nltk/metrics/scores.py", line 16, in <module>
    from scipy.stats.stats import betai
  File "/usr/lib/python2.7/dist-packages/scipy/stats/__init__.py", line 7, in <module>
    from stats import *
  File "/usr/lib/python2.7/dist-packages/scipy/stats/stats.py", line 198, in <module>
    import distributions
  File "/usr/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 87, in <module>
    from new import instancemethod
  File "new.py", line 3

        ^
IndentationError: expected an indented block

/usr/lib/python2.7/ で見つけた new.py を調べたところ、すべて問題ないことがわかりました。

"""Create new objects of various types. 
 Deprecated.This module is no longer required except for backward compatibility.
 Objects of most types can now be created by calling the type object.
"""
from warnings import warnpy3k
warnpy3k("The 'new' module has been removed in Python 3.0; use the 'types' "
            "module instead.", stacklevel=2)
del warnpy3k

from types import ClassType as classobj
from types import FunctionType as function
from types import InstanceType as instance
from types import MethodType as instancemethod
from types import ModuleType as module

from types import CodeType as code

解決策はありますか?

4

1 に答える 1

3

という名前のローカルファイルがありますnew.py。現在のディレクトリを確認し、名前を変更するか削除してください。

これはトレースバックで確認できます。

  File "/usr/lib/python2.7/dist-packages/scipy/stats/distributions.py", line 87, in <module>
    from new import instancemethod
  File "new.py", line 3

前のモジュールには完全なファイルパスがありますが、new.pyファイルにはありませんscipy.stats.distributions。.

于 2013-01-01T11:32:08.817 に答える