gpt4 book ai didi

python - 导入错误 : cannot import name wsgiserver

转载 作者:太空宇宙 更新时间:2023-11-03 13:57:04 35 4
gpt4 key购买 nike

运行 python 脚本时出现以下错误

    Traceback (most recent call last):
File "SampleWSTest.py", line 10, in <module>
from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter
File "C:\Python27\lib\site-packages\web\wsgiserver\ssl_builtin.py", line 14, in <module>
from cherrypy import wsgiserver
ImportError: cannot import name wsgiserver

在 python 2.7.15 上运行

import web
import sys
import argparse
import traceback
from web.wsgiserver import CherryPyWSGIServer
from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter
from OpenSSL import SSL

class Healthcheck:
def GET(self):
return 'Yassssssssss !!!!!'

URLS = ('/svc/healthcheck', 'Healthcheck')

CherryPyWSGIServer.ssl_certificate = 'alice.crt'
CherryPyWSGIServer.ssl_private_key = 'alice.key'

if __name__ == '__main__':
CherryPyWSGIServer.ssl_adapter = BuiltinSSLAdapter(CherryPyWSGIServer.ssl_certificate, CherryPyWSGIServer.ssl_private_key)
CherryPyWSGIServer.ssl_adapter.context = SSL.Context(SSL.SSLv23_METHOD)
CherryPyWSGIServer.ssl_adapter.context.set_options(SSL.OP_NO_SSLv3)
CherryPyWSGIServer.ssl_adapter.context.use_certificate_file(CherryPyWSGIServer.ssl_certificate)
CherryPyWSGIServer.ssl_adapter.context.use_privatekey_file(CherryPyWSGIServer.ssl_private_key)
app = web.application(URLS, globals())
app.run()

这在我们不得不禁用 ssl 2ssl 3 之后开始失败,因此不得不添加 ssl_adapter 但 BuiltinSSLAdapter 导入失败。如果有任何其他选择,请提出建议。基本上想禁用 ssl 2ssl 3 之前我们没有 from web.wsgiserver.ssl_builtin import BuiltinSSLAdapter从 OpenSSL 导入 SSL

最佳答案

CherryPy 于 2017 年将 wsgiserver 移至 cheroot。

http://docs.cherrypy.dev/en/latest/history.html#v9-0-0

所以现在你需要像这样导入它:

from cheroot.wsgi import Server as CherryPyWSGIServer

或在整个过程中重命名。

关于python - 导入错误 : cannot import name wsgiserver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59372836/

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