Python33,Flask:很多错误启动Hello World

时间:2014-07-30 16:49:35

标签: python windows flask

我刚刚在我的window-sytem上安装了pip flask和HTML5。当我使用IDLE启动Hello World!-program时,我在Firefox的新选项卡中获得了正确的文本。但是在Python shell中还有很多错误消息:

    Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 1519, in _find_and_load_unlocked
    AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:\Python33\lib\site-packages\werkzeug\utils.py", line 18, in <module>
        from html.entities import name2codepoint
    ImportError: No module named 'html.entities'; html is not a package

During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "C:/Users/Public/python/testflask.py", line 13, in <module>
        from flask import Flask
      File "C:\Python33\lib\site-packages\flask\__init__.py", line 17, in <module>
        from werkzeug.exceptions import abort
      File "C:\Python33\lib\site-packages\werkzeug\__init__.py", line 154, in <module>
        __import__('werkzeug.exceptions')
      File "C:\Python33\lib\site-packages\werkzeug\exceptions.py", line 71, in <module>
        from werkzeug.wrappers import Response
      File "C:\Python33\lib\site-packages\werkzeug\wrappers.py", line 36, in <module>
        from werkzeug.utils import cached_property, environ_property, \
      File "C:\Python33\lib\site-packages\werkzeug\utils.py", line 20, in <module>
        from htmlentitydefs import name2codepoint
    ImportError: No module named 'htmlentitydefs'

帮助!救命!救命啊!

1 个答案:

答案 0 :(得分:2)

您有一个隐藏内置库的本地 html.py模块或html包。重命名它,因为它打破了依赖于标准库版本的软件。

您可以找到需要重命名的文件或移到一边:

import html
print(html)

将该文件重命名为其他内容。考虑到可能还有一个.pyc文件;如果存在,则删除.pyc字节码缓存altogeher。