gpt4 book ai didi

python - 模块未找到错误 : No module named 'BaseHTTPServer'

转载 作者:太空狗 更新时间:2023-10-30 02:26:23 26 4
gpt4 key购买 nike

因此,我尝试按照有关如何使用 web.py 的在线教程进行操作,并且安装了它,但不幸的是,使用这段代码会产生严重的错误。我的代码...

import web

urls = (
'/(.*)', 'index'
)

app = web.application(urls, globals())


class index:
def GET(self, name):
return "Hello", name, '. How are you today?'

if __name__== "__main__":
app.run()

我的错误:

C:\Users\User\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/User/PycharmProjects/Webprojects/main.py

Traceback (most recent call last):
File "C:/Users/User/PycharmProjects/Webprojects/main.py", line 15, in <module>
app.run()
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\application.py", line 312, in run
return wsgi.runwsgi(self.wsgifunc(*middleware))
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\wsgi.py", line 59, in runwsgi
return httpserver.runsimple(func, server_addr)
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\httpserver.py", line 154, in runsimple
func = LogMiddleware(func)
File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\httpserver.py", line 296, in __init__
from BaseHTTPServer import BaseHTTPRequestHandler
ModuleNotFoundError: No module named 'BaseHTTPServer'

Process finished with exit code 1

最佳答案

该导入行在将 BaseHTTPServer 移动到 http.server 的 Python 3 中不起作用

在您的特定情况下,您应该将 web.py 更新为适用于 Python 3 的当前版本。

关于python - 模块未找到错误 : No module named 'BaseHTTPServer' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45229030/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com