準備研究一下python web框架,用的是flask.寫了幾行代碼,卻總是報錯,特來請教一下大佬:
代碼如下:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello() -> str:
return 'hello world from flask'
app.run()
flask模塊也安裝了,運行后報錯如下
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/werkzeug/utils.py", line 30, in <module>
from html.entities import name2codepoint
File "/opt/html/html.py", line 1, in <module>
from flask import Flask
ImportError: cannot import name 'Flask'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "html.py", line 1, in <module>
from flask import Flask
File "/usr/local/lib64/python3.6/site-packages/flask/__init__.py", line 16, in <module>
from werkzeug.exceptions import abort
File "/usr/local/lib/python3.6/site-packages/werkzeug/__init__.py", line 15, in <module>
from .serving import run_simple
File "/usr/local/lib/python3.6/site-packages/werkzeug/serving.py", line 51, in <module>
from .exceptions import InternalServerError
File "/usr/local/lib/python3.6/site-packages/werkzeug/exceptions.py", line 68, in <module>
from .utils import escape
File "/usr/local/lib/python3.6/site-packages/werkzeug/utils.py", line 32, in <module>
from htmlentitydefs import name2codepoint
ModuleNotFoundError: No module named 'htmlentitydefs'
為什么總是提示不能匯入flask模塊,還有,就是ModuleNotFoundError: No module named 'htmlentitydefs' 這個是個什么鬼?請大神賜教!!
uj5u.com熱心網友回復:
看看你的 /opt/html/目錄下有沒有 flask 目錄 或者 flask.py 檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/227947.html
上一篇:Python里解一元二次方程時用lambda函式出現了TypeError: '<' not supported between instances of 'fu
下一篇:sv 新人求助
