I need to change the keras backend from default tensorflow to theano. But my default python version is 3.7, which does not seem to work with keras (the import line crashes). So, I first had to create a specific environment.
After creating a specific python environment with anaconda, as suggested by 47263006, I did the following:
vi ~/.keras/keras.json (and change the backend name in it)
But with a virtualenv, editing the keras.json file had no effect. So, I resorted to the following solution in the python code:
import os
os.environ['KERAS_BACKEND'] = 'theano'
So I thought that maybe the latter is the more generic soution, and I tried to use it with my anaconda env, but surprise - that did not work there.
So my current solution is that, for anaconda edit the keras.json file and for virtualenv use os.environ.
Is there a more generic solution for setting keras backend which will work for both conda and virtualenv?