SOLVED!: Why does the import of Keras fail with JsonDecodeError

The cause of the problem was some python comments in the top of the keras.py file that configures it to use Theano as the backend.

Once I deleted those comments, the import of keras is successful. :grinning:


I followed the step by step Theano and Keras installation instructions for windows 10 as per the suggested resource at http://ankivil.com/installing-keras-theano-and-dependencies-on-windows-10/

Everything worked fine, until it came to testing the keras installation. That’s when I get this error when just executing the import keras command inside the test py file. What else can I do to troubleshoot this?

import keras
Traceback (most recent call last):

File “”, line 1, in
import keras

File “C:\Program Files\Anaconda3\lib\site-packages\keras\keras_init_.py”, line 2, in
from . import backend

File “C:\Program Files\Anaconda3\lib\site-packages\keras\keras\backend_init_.py”, line 31, in
_config = json.load(open(_config_path))

File “C:\Program Files\Anaconda3\lib\json_init_.py”, line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)

File “C:\Program Files\Anaconda3\lib\json_init_.py”, line 319, in loads
return _default_decoder.decode(s)

File “C:\Program Files\Anaconda3\lib\json\decoder.py”, line 342, in decode
raise JSONDecodeError(“Extra data”, s, end)

JSONDecodeError: Extra data

1 Like

@elle_idan Glad you sovled it! Thanks for posting your solution

In which location you found the keras.py file which had theano comments ? Couldn’t find and solve my issue.