2016-04-16 8 views
1

nltkを使用して、Python 3.4のPyCharmで英語を解析していました。私は私のファイルを実行したときに、私は次のエラー受信:site.py:AttributeError:PyCharmで任意のPythonファイルを実行すると、 'module'オブジェクトに 'ModuleType'属性がありません

Error processing line 1 of /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/zope.interface-4.1.3-py3.4-nspkg.pth: 

    Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site.py", line 167, in addpackage 
     exec(line) 
    File "<string>", line 1, in <module> 
    AttributeError: 'module' object has no attribute 'ModuleType' 

Remainder of file ignored 

空のファイルをデバッグする私を取得します。少し工夫した後

Error processing line 1 of /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/zope.interface-4.1.3-py3.4-nspkg.pth: 

    Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site.py", line 167, in addpackage 
     exec(line) 
    File "<string>", line 1, in <module> 
    AttributeError: 'module' object has no attribute 'ModuleType' 

Remainder of file ignored 
Traceback (most recent call last): 
    File "/Users/james/naturallang/grammar.py", line 3, in <module> 
    import nltk.book 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nltk/__init__.py", line 89, in <module> 
    from nltk.internals import config_java 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/nltk/internals.py", line 11, in <module> 
    import subprocess 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 424, in <module> 
    _PopenSelector = selectors.SelectSelector 
AttributeError: 'module' object has no attribute 'SelectSelector' 

を、私は空のファイルを実行すると、私は次のエラーを与えたことがわかりました:私はOS X上でPyCharm 5.04 Professionalエディションを使用しています

Error processing line 1 of /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/zope.interface-4.1.3-py3.4-nspkg.pth: 

    Traceback (most recent call last): 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site.py", line 167, in addpackage 
     exec(line) 
    File "<string>", line 1, in <module> 
    AttributeError: 'module' object has no attribute 'ModuleType' 

Remainder of file ignored 
Traceback (most recent call last): 
    File "/Applications/PyCharm.app/Contents/helpers/pydev/pydev_imports.py", line 9, in <module> 
    import xmlrpclib 
ImportError: No module named 'xmlrpclib' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/Applications/PyCharm.app/Contents/helpers/pydev/pydev_imports.py", line 11, in <module> 
    import xmlrpc.client as xmlrpclib 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/xmlrpc/client.py", line 135, in <module> 
    import http.client 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 69, in <module> 
    import email.parser 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/parser.py", line 12, in <module> 
    from email.feedparser import FeedParser, BytesFeedParser 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/feedparser.py", line 27, in <module> 
    from email import message 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/message.py", line 16, in <module> 
    from email import utils 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/email/utils.py", line 28, in <module> 
    import random 
    File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/random.py", line 40, in <module> 
    from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType 
ImportError: cannot import name 'MethodType' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 10, in <module> 
    import pydev_imports 
    File "/Applications/PyCharm.app/Contents/helpers/pydev/pydev_imports.py", line 13, in <module> 
    from _pydev_imps import _pydev_xmlrpclib as xmlrpclib 
    File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_xmlrpclib.py", line 294 
    True, False = True, False 
    ^
SyntaxError: can't assign to keyword 

私はこれが私のエディタとは何かを持っているを考えるが、私はよく分かりません。

+1

'types'モジュールに何か問題があるようです。現在のディレクトリに 'types.py'という名前のファイルがありますか? – ppperry

+0

@ppperryそれが解決しました!あなたが回答を投稿した場合、私はそれを受け入れます。 –

+0

回答を追加 – ppperry

答えて

2

現在のディレクトリにtypes.pyという名前のファイルがあります。

このファイルは、標準ライブラリの一部であるtypesモジュールをシャドウします。 nltkプログラムは(間接的に)typesを間接的にインポートしようとしましたが、ModuleType属性を持たないモジュールはImportErrorになります。これは決して捕捉されず、そのトレースバックを生成します。

関連する問題