I gave a solution (not sure if can work for every case, but worked well for me) in https://stackoverflow.com/a/57475559/9531617. To quote myself:
The problem can be fixed without modifying the sources by simply installing ipykernel
and importing it in your code:
pip install ipykernel
Then
import ipykernel
In fact, in the Keras generic_utils.py file, the probematic line was (in my case):
if self._dynamic_display:
sys.stdout.write('\b' * prev_total_width)
sys.stdout.write('\r')
else:
sys.stdout.write('\n')
Where the self._dynamic_display
was False
, whereas it needed to be True to work properly. But the value self._dynamic_display was initiated such as:
self._dynamic_display = ((hasattr(sys.stdout, 'isatty') and
sys.stdout.isatty()) or
'ipykernel' in sys.modules)
So, loading ipykernel
added it to sys.modules
and fixed the problem for me.