我有一个奇怪的错误,我以前从未见过
我使用flask编写了一个小型http web服务器,当我运行时,出现了下面的错误
我使用的是虚拟环境,我的python版本是3.8
可能是什么
from flask import Flask, request
app = Flask(__name__)
@app.route("/")
def index():
print(request.get_json())
if __name__ == "__main__":
app.run(debug=True)
python tools/fake.pyTraceback (most recent call last):
File "/home/ubuntu/workspace/otc/venv/lib/python3.8/site-packages/werkzeug/serving.py", line 58, in <module>
from http.server import BaseHTTPRequestHandler
ModuleNotFoundError: No module named 'http.server'; 'http' is not a package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tools/fake.py", line 1, in <module>
from flask import Flask, request
File "/home/ubuntu/workspace/otc/venv/lib/python3.8/site-packages/flask/__init__.py", line 16, in <module>
from werkzeug.exceptions import abort
File "/home/ubuntu/workspace/otc/venv/lib/python3.8/site-packages/werkzeug/__init__.py", line 15, in <module>
from .serving import run_simple
File "/home/ubuntu/workspace/otc/venv/lib/python3.8/site-packages/werkzeug/serving.py", line 61, in <module>
import SocketServer as socketserver
ModuleNotFoundError: No module named 'SocketServer'```
这也许对你有帮助 `
`
问题来自第一次回溯:
您需要将
http.py
文件重命名为其他文件,因为它正在重写标准库http
模块。要修复它,您需要执行以下操作:http.py
重命名为其他文件李>.pyc
文件Python3使用
socketserver
,全部小写。Python2使用SocketServer
相关问题 更多 >
编程相关推荐