Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asrserver运行client报错500,'Request' object has no attribute 'get_json' #299

Open
twnDrmSnw opened this issue Aug 8, 2022 · 2 comments

Comments

@twnDrmSnw
Copy link

twnDrmSnw commented Aug 8, 2022

背景:下载ASRT_v1.3.0.zip包,无代码修改,Python3.7,依赖包为requirements.txt无修改,运行asrserver_http无报错,运行client_http时,client报错如下:

Traceback (most recent call last):
File "D:/Prj/PycharmPrj/ASRT_v1.3.0/client_http.py", line 47, in
result = json.loads(r.text)
File "D:\Env\Python37\lib\json_init_.py", line 348, in loads
return _default_decoder.decode(s)
File "D:\Env\Python37\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\Env\Python37\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

asrserver报错如下:

[2022-08-08 14:52:05,666] ERROR in app: Exception on /all [POST]
Traceback (most recent call last):
File "D:/Prj/PycharmPrj/ASRT_v1.3.0/asrserver_http.py", line 148, in recognition_post
request_data = request.get_json()
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\venv\lib\site-packages\werkzeug\local.py", line 348, in getattr
return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'get_json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 1519, in full_dispatch_request
rv = self.handle_user_exception(e)
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 1517, in full_dispatch_request
rv = self.dispatch_request()
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 1503, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "D:/Prj/PycharmPrj/ASRT_v1.3.0/asrserver_http.py", line 174, in recognition_post
request_data = request.get_json()
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\venv\lib\site-packages\werkzeug\local.py", line 348, in getattr
return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'get_json'
127.0.0.1 - - [08/Aug/2022 14:52:05] "POST /all HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\asrserver_http.py", line 148, in recognition_post
request_data = request.get_json()
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\venv\lib\site-packages\werkzeug\local.py", line 348, in getattr
return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'get_json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 1519, in full_dispatch_request
rv = self.handle_user_exception(e)
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 1517, in full_dispatch_request
rv = self.dispatch_request()
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 1503, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\asrserver_http.py", line 174, in recognition_post
request_data = request.get_json()
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\venv\lib\site-packages\werkzeug\local.py", line 348, in getattr
return getattr(self._get_current_object(), name)
AttributeError: 'Request' object has no attribute 'get_json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\venv\lib\site-packages\werkzeug\serving.py", line 304, in run_wsgi
execute(self.server.app)
File "D:\Prj\PycharmPrj\ASRT_v1.3.0\venv\lib\site-packages\werkzeug\serving.py", line 292, in execute
application_iter = app(environ, start_response)
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 2091, in call
return self.wsgi_app(environ, start_response)
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "D:\Env\Python37\lib\site-packages\flask\app.py", line 1428, in handle_exception
server_error = InternalServerError(original_exception=e)
TypeError: init() got an unexpected keyword argument 'original_exception'

求助,万分感谢!

@nl8590687
Copy link
Owner

请检查软硬件环境的版本

@twnDrmSnw
Copy link
Author

已解决,原因是没有通过requirements手动导入的Flask默认版本太高,降至0.12.5即可(pycharm会默认安装2.2.2版本Flask)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants