简体   繁体   English

site.py:AttributeError:在PyCharm中运行任何python文件时,“模块”对象没有属性“ ModuleType”

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

I was using nltk to parse english on Python 3.4 with PyCharm. 我使用nltk在带有PyCharm的Python 3.4上解析英语。 When I ran my file, I received the following error: 运行文件时,出现以下错误:

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'

After a little tinkering, I found that running an empty file gave me the following error: 稍作修改后,我发现运行一个空文件给我以下错误:

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

Debugging an empty file gets me: 调试一个空文件使我:

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

I am using PyCharm 5.04 Professional Edition on OS X. I think this has something to do with my editor, but I'm not sure. 我在OS X上使用PyCharm 5.04 Professional Edition。我认为这与我的编辑器有关,但我不确定。

There is a file named types.py in your current directory. 当前目录中有一个名为types.py的文件。

This file shadows the types module that is part of the standard library. 此文件遮盖了标准库中的types模块。 The nltk program (very) indirectly tries to import types , getting your module, which lacks a ModuleType attribute, causing an ImportError , which never gets caught and produces that traceback. nltk程序(非常)间接尝试导入types ,获取缺少ModuleType属性的模块,从而导致ImportError ,该ImportError永远不会被捕获并产生该回溯。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python + PyCharm 文件结构问题:AttributeError: 'module' object 没有属性 'X' - Python + PyCharm File Structure issue: AttributeError: 'module' object has no attribute 'X' AttributeError:“模块”对象没有属性“ maketrans”-PyCharm - AttributeError: 'module' object has no attribute 'maketrans' - PyCharm AttributeError: &#39;module&#39; 对象没有运行 pip 的属性 &#39;python_implementation&#39; - AttributeError: 'module' object has no attribute 'python_implementation' running pip AttributeError:在Atom中运行python时,“模块”对象没有属性“随机” - AttributeError: 'module' object has no attribute 'random' when running python in Atom AttributeError:&#39;module&#39;对象在运行flask项目的主python文件时没有属性&#39;getargspec&#39; - AttributeError: 'module' object has no attribute 'getargspec' while running a main python file of the flask project PyCharm无缘无故地运行测试时抛出“AttributeError:&#39;模块&#39;对象没有属性” - PyCharm throws “AttributeError: 'module' object has no attribute” when running tests for no reason 删除site.py后,Python失败 - Python fails after deleting site.py python:lib / site-packages / site.py和lib / site.py之间的相互作用 - python: Interplay between lib/site-packages/site.py and lib/site.py 无法在PyCharm 5.0中调试Python脚本:AttributeError:“模块”对象没有属性“ default_getpass” - Can't debug Python script in PyCharm 5.0: `AttributeError: 'module' object has no attribute 'default_getpass'` Pycharm python AttributeError:模块&#39;urllib3&#39;没有属性&#39;Request&#39; - Pycharm python AttributeError: module 'urllib3' has no attribute 'Request'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM