0

i installed keras 1.1 version and theano 0.8.2 version on a python2.7 anaconda virtualenvironment on windows 10 machine to run this repo the installation went fine but when i try to import keras in python shell it gives me this error

>>> import theano
>>> import keras
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Kattooparambil\Anaconda3\envs\mainproject\lib\site-packages\keras\__init__.py", line 2, in <module>
    from . import backend
  File "C:\Users\Kattooparambil\Anaconda3\envs\mainproject\lib\site-packages\keras\backend\__init__.py", line 29, in <module>
    _config = json.load(open(_config_path))
  File "C:\Users\Kattooparambil\Anaconda3\envs\mainproject\lib\json\__init__.py", line 291, in load
    **kw)
  File "C:\Users\Kattooparambil\Anaconda3\envs\mainproject\lib\json\__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Kattooparambil\Anaconda3\envs\mainproject\lib\json\decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Kattooparambil\Anaconda3\envs\mainproject\lib\json\decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 7 column 2 (char 145)
>>>

i dont know the reason for the error , im guessing it has something to do with windows and keras 1.1 incompatiblity

The contents of .keras/keras.json file

{
  "floatx": "float32",
     "epsilon": 1e-07,
     "backend": "theano",
    "image_data_format": "channels_last",
"image_dim_ordering": "th",
 }

The steps i did to reach this stage as said in this thread .i created a virtualenv with python2.7 in anaconda3

enter image description here

started the virtualenv terminal

pip install keras==1.1.0 h5py theano==0.8.2 librosa

and the imported keras and it gives me this error

Any help is greatly appreciated

Albin Paul
  • 3,330
  • 2
  • 14
  • 30
  • Check the contents of the keras.json file, I have no idea where it is located in Windows, but should be somewhere. If you find that file, paste its contents here. – Dr. Snoopy Feb 10 '18 at 19:14
  • @MatiasValdenegro i have added the contents of the file found it by using [question](https://stackoverflow.com/questions/40310035/how-to-change-keras-backend-wheres-the-json-file) and i tried changing the image-data-format from channels_last to channels_first but it was no good – Albin Paul Feb 11 '18 at 02:22

2 Answers2

1

Your keras.json has a small typo, there is a comma after the last entry, which should not be there, as there is no following entry:

{
     "floatx": "float32",
     "epsilon": 1e-07,
     "backend": "theano",
    "image_data_format": "channels_last",
    "image_dim_ordering": "th"
 }

In general if you import Keras and some json function errors, this points to your Keras configuration file (keras.json) having the wrong syntax.

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140
  • thanks alot , as it is a typo error .should i delete the question ? – Albin Paul Feb 11 '18 at 09:21
  • No, from the initial error message its not obvious that its a typo in the configuration file, so I think it should be kept. Maybe you can edit the title to reflect the error message so other people with the same issue can find it more easy. Other questions referring to the same typo should be marked as duplicate of this one. – Dr. Snoopy Feb 11 '18 at 09:25
0

Anaconda3 means it has python3.x version, so i think making a virtual environment with anaonda3 and python2.7 will generate error. try making a virtual environment will python 3.x. hope it helps.

Khan
  • 1,288
  • 12
  • 11
  • it has the option to generate environment for python2.7 and python3.5 and python3.6 , the environment runs fine . i want the the project to run on python 2.7 as said in the github repository . or i have to convert all the code in the repo written in python2 to python3 using the python 2to3 module and give a go but i want to know if there is a workaround – Albin Paul Feb 10 '18 at 17:19