Question

ImportError: cannot import name 'JSONDecodeError' from 'requests.exceptions'

  • 19 October 2023
  • 1 reply
  • 2060 views

while running python program using streamsets python sdk we are getting error 

File "/var/lib/jenkins/.local/lib/python3.8/site-packages/streamsets/sdk/exceptions.py", line 5, in <module> from requests.exceptions import HTTPError, JSONDecodeError ImportError: cannot import name 'JSONDecodeError' from 'requests.exceptions'

we have found solution for this but we want to know why we are getting this error.
Solution for this is manually we are replacing line “from requests.exceptions import HTTPError, JSONDecodeError”   with 
“from json import JSONDecodeError”


1 reply

Userlevel 1
Badge

I have seen this problem when ‘requests’ is outdated. It looks like JSONDecodeError was added in requests 2.27.0. Update your requests package to see the proper error message.

Reply