While using beautifulsoup parsing a page, I got following warning. Although I ignored this warning for sometime, it started to become distracting to see this warning every time I run my program.
UserWarning: No parser was explicitly specified, so I'm u sing the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtua l environment, it may use a different parser and behave differently. The code that caused this warning is on line 12 of the file filename.py. To get rid of this warning, pass the additional argument 'features="lxml"' to th e BeautifulSoup constructor.
There is nothing wrong with this warning and you can continue your coding however I wanted to get it corrected due to following
- Its distracting to see this error every time I run my program
- If I run my program on some other machine, it might not perform as expected since system will chose which is available.
Besides these two primary error, I get an itching if I see unformated code or uncesessary warinings. Many time I havr burned by fingures while correcting warnings (read , i was able to fix warning but it led to errors and the whole process ate considerable amount of my time.)
Don’t worry, fixing above error would not lead to an error.
Before fixing this error, install lxml
pip install lxml
To fix this warning, simple replace following line
soup = BeautifulSoup(data)
with this line
soup = BeautifulSoup(data, features = "lxml")
Now run your program and it will run without any warning.