簡體   English   中英

site.py:AttributeError:在PyCharm中運行任何python文件時,“模塊”對象沒有屬性“ ModuleType”

[英]site.py: AttributeError: 'module' object has no attribute 'ModuleType' upon running any python file in PyCharm

我使用nltk在帶有PyCharm的Python 3.4上解析英語。 運行文件時,出現以下錯誤:

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'

稍作修改后,我發現運行一個空文件給我以下錯誤:

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 "/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

我在OS X上使用PyCharm 5.04 Professional Edition。我認為這與我的編輯器有關,但我不確定。

當前目錄中有一個名為types.py的文件。

此文件遮蓋了標准庫中的types模塊。 nltk程序(非常)間接嘗試導入types ,獲取缺少ModuleType屬性的模塊,從而導致ImportError ,該ImportError永遠不會被捕獲並產生該回溯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM