I have now tracked the problem to be caused by the extension. Once I rename this file C:\Users\X\.jupyter\nbconfig\notebook.json to something else and reopen jupyter notebook, the print works as expected.
However, I do need the extensions at least the key ones I use regularly. I don't know which one to disable. I didn't know how to track the culprit without going through each one by one. Also, as far as I can remember, all the extensions I have been using for few weeks already without any issues.
These are the contents of the notebook.json file.
{
"load_extensions": {
"toc2/main": true,
"Runtools": true,
"collapsible_headings/main": true,
"codefolding/main": true,
"varInspector/main": true,
"runtools/main": true,
"runtools": true
},
"collapsible_headings": {
"add_button": true,
"add_insert_header_buttons": true
}
}
After trial and error with disabling one every time, restart and check.. I have now solved the problem by setting this line to false, it now works. The problem is with variable inspector extension.
"varInspector/main": false,
Sometimes the jupyter required a restart and sometime it didn't. Just opening the .ipynb file was enough to test.
I have the same extension running in my office computer, which has no issues.
If someone could really put in the comments for the cause and a solution for permanent fix of this problem will be great.