In Jupyter Notebook, how can I log on the log console (shown in View
→ Show Log Console
) the output of some log from a Python file dependency?
In myNoteBook.ipynb
file I have:
import myfile
myfile.test()
In myfile.py
I have
def test():
print('Hello')
How can I see “Hello” in the Log Console when I run myNoteBook.ipynb
?
Posted also on SO
setting the log level in Log Console to info
or debug
should work
1 Like
mind questioning how do I do that?
Thanks in advance
There’s a dropdown for the ‘Log Level’ setting along the top of the console.
Here shows it set to ‘Debug’:
And the first line in the myNoteBook.ipynb
file should be import myfile
2 Likes
This makes me think you mean JupyterLab and not Jupyter Notebook? But maybe your interface has more options than mine?
1 Like
I’m not fully sure also to be honest. But does it make any difference? Thanks
Yes, it matters for categorizing the discussion topics as well as the interfaces are very different. For example, you posted this categorized under ‘Notebook’ when I think it might be meant for JupyterLab. It will be less of a help to all involved if classified wrong.
As far as I know classic Jupyter Notebook and Jupyter Notebook 7+ don’t have that menu path to the Log Console.
Possibly confusing users about what is available in what interface is something we want to avoid. It also helps us talk about the same thing. For example, I included an image illustrating how to toggle the Log level, but I’m not sure it was pertinent to your interface? I don’t want to be posting unrelated images that might confuse you and others following in our footsteps & trying to learn.
It is best to pretty much always check what tech and version is under ‘About’ and endeavor to include that information in posts at forums such as this and StackOverfow.
Alternative: Because for certain uses of Jupyter .ipynb
files, such as running animated plots or troubleshooting ipywidgets, need particular approaches to function well in particular Jupyter interfaces at this time in the ecosystem, keeping straight where you are working is important. And so to help people working with that, I tried to describe some quick ways to keep track of what interface you are working in. This information is in this gist ‘Guide to distinguishing Jupyter interfaces early 2024’ here.
2 Likes
Edited accordingly, thanks
Thanks, I will take that in mind for future posts.
I’m just a newbie end user of the service here at my organization, I couldn’t yet grap the difference between the both.
No problem at all. We all started somewhere and we try to keep things organized so it helps others on the learning curve.