How to suppress/hide all the warnings in IJulia or Julia language?

There are a lot of warnings which are always of no need to be fixed, while including code files. This makes the IJulia page messy. How to hide these warnings in Julia language or IJulia? Can anyone help? Thanks!

There is an example of the ugly notebook page caused by the warnings as follows.

Install an IJulia kernel with deprecation warnings turned off, from the IJulia README:

using IJulia
IJulia.installkernel("Julia nodeps", "--depwarn=no")

Thanks for your swift reply!

Thanks for your swift reply! I have tried but got an error of no definition of installkernel() function.
I use Julia 0.5.2, IJulia 1.5.1, on windows 7.

I also tested addkernel() function. Also got the error of “no function defined”.



These are not deprecation warnings. Ref

@kristoffer.carlsson Totally agree with you. It is the common workflow to redefine the function during developing and testing. I write the functions using Juno, and calling them in IJulia to show the results. It works well for me. The only pain thing is the ugly IJulia notebook caused by the large amount of warnings.

I try to fix it with the following code suggested by @stevengj. However, the code can not run correctly.

using IJulia
IJulia.installkernel("Julia nodeps", "--depwarn=no")

I use Julia 0.5.2, IJulia1.5 on windows 7.

I haven’t tagged a new release of IJulia with this function yet. Do Pkg.checkout("IJulia") to get this feature.

@stevengj Thanks for your reply. I am able to run “installkernel()” and also able to change to the new kernel. However, the warnings are still there. I found that this function created a new kernel.json adding a new parameter of “–depwarn=no”.
In fact, before posting this question I have already tried to add this to kernel.json manually. But, it does not work it only suppresses the deprecation warnings.

Thank you so much for your help. By the way, the package of PyCall.jl and PyPlot.jl are extremely helpful. Without these two packages, maybe I cannot keep on using Julia. I can use many packages from Python which are still not existed in Julia. Thanks for your great work!

As I said, these are not deprecation warnings…

Yes, as @kristoffer.carlsson pointed out, the specific warnings you are showing are not deprecation warnings, so they won’t be affected by --depwarn=no.

You might try upgrading to Julia 0.6. Not only is Julia 0.6 better than 0.5 in many ways, it also does not emit a warning for redefining a method in the Main namespace (the one used for interactive definitions): don't warn about redefining methods in Main by stevengj · Pull Request #19888 · JuliaLang/julia · GitHub

Thanks for your reminding! In fact, I want to suppress all warnings including deprecation warnings, which make the notebook page ugly.

Thanks! I have tried. But there are still other warnings. In fact, I want to suppress all warnings to make the IJulia notebook clean.

That should be fixed: just like we don’t warn for redefining methods in Main, we shouldn’t warn for redefining docstrings in Main. I’ll look into filing a PR: don't warn about redefining docstrings in Main · Issue #23011 · JuliaLang/julia · GitHub

In the meantime, however, the presence of all of these warning suggests that you may have a coding style that is not idiomatic for Julia. Why are you including code files that redefine the same functions over and over?

@stevengj Thanks for your suggestion. Most of the time, the warnings indicate the potential improper coding.

The “redefine the same functions” may be caused by two reasons
(a) I “include()” code files repeatedly in the *.jl files. (b) It is related to the workflow. I edit the code files in Juno and call the functions and check the result in IJulia. If the result is not good enough, I revise the code in Juno and “include()” the code file in IJulia again. I found this workflow is quite convenient for me.

Thank you so much. I will check my code. ? You could also use no_warnings() do; include(...) end to remove all of them. Or It was a common ailment in Julia 0.5.


Suppressor.jl is AWESOME! Finally a clean notebook!

1 Like

For global suppression of logging at different levels such as debug, info, warn, or error, use the following (I’ve confirmed that it works in iJulia in Jupyter Lab/Notebook):


This suppresses all messages/logging for debug and info. This can be referenced in Julia docs logging.

1 Like

…and for more precise suppression, use the filtered loggers from LoggingExtras.jl.
e.g. the following demo is very applicable:

(Posting this here as this page is the top google result for “julia ignore warning”; and it was the solution that worked for me, after trying the above).