Home > Article > Backend Development > How to ignore warning errors in Python
I was running a python file and kept getting warning errors. I was very depressed, so I thought I could ignore these errors.
Here’s how to ignore these warnings.
python -W ignore yourscript.py
import warnings def fxn(): warnings.warn("deprecated", DeprecationWarning) with warnings.catch_warnings(): warnings.simplefilter("ignore") fxn()
If you don’t want to use the above method, you can add the following code directly at the beginning of the python source code:
import warnings warnings.filterwarnings("ignore")
This way you can ignore the python warning Wrong