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

question

#1

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.
https://github.com/dmoliveira/my-juliabox/blob/master/Data%20Analysis%20-%20Julia%20%2B%20Gadfly%20-%20Scatter-Matrix%20Example.ipynb


#2

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

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

#3

Thanks for your swift reply!


#4

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”.

Thanks!

捕获


#5

These are not deprecation warnings. Ref https://github.com/JuliaLang/julia/pull/23002


#6

@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.


#7

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


#8

@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!


#9

As I said, these are not deprecation warnings…


#10

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): https://github.com/JuliaLang/julia/pull/19888


#11

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


#12

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


#13

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: https://github.com/JuliaLang/julia/issues/23011

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?


#14

@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.


#15

https://github.com/cstjean/ClobberingReload.jl#silencing-warnings ? You could also use no_warnings() do; include(...) end to remove all of them. Or https://github.com/Ismael-VC/Suppressor.jl. It was a common ailment in Julia 0.5.


#16

Suppressor.jl is AWESOME! Finally a clean notebook!