Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python3: unable to import JSONDecodeError from json.decoder

I setup virtualenv using python 3.4.3 and tried to import JSONDecodeError from json.decoder

from json.decoder import JSONDecodeError (I think its valid in python3 ? But why not working for me ?) 

But it is not working. Only below is working:

from simplejson import JSONDecodeError

How I did ?

virtualenv venv --no-site-packages -p python3 
pip install ipython
ipython
from json.decoder import JSONDecodeError
ImportError: cannot import name 'JSONDecodeError'

enter image description here

like image 396
user2349115 Avatar asked Jun 23 '17 05:06

user2349115


Video Answer


1 Answers

According to 3.4.x docs, plain ValueError is raised when JSON decoding fails.

JSONDecodeError class is available starting from 3.5.x.

like image 191
Łukasz Rogalski Avatar answered Sep 21 '22 22:09

Łukasz Rogalski