2

So I'm testing PyDictionary out for a project, and so have written out a very short program just to make sure i've installed it properly and so on

from PyDictionary import PyDictionary
dictionary=PyDictionary()

var = dictionary.synonym("life")

print var

And this works, however, it also returns the following before it prints the list of synonyms.

.local/lib/python2.7/site-packages/bs4/__init__.py:181: UserWarning: No parser was explicitly specified, so I'm using 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 virtual environment, it may use a different parser and behave differently.

The code that caused this warning is on line 4 of the file dicttest.py. To get rid of this warning, change code that looks like this:

 BeautifulSoup([your markup])

to this:

 BeautifulSoup([your markup], "lxml")

 markup_type=markup_type))

I am not sure what to change my code to, to remove this issue. I thought maybe changing line 4 to var = (dictionary.synonym("life"), "lxml") might help, and tried variations of it, but the error still appears. Maybe there is a variation I've missed. Overall I'm not sure what to do.

Cheers for any help you can give.

Edit: Other answers have been pointed out to me, which make it seem like a simple fix, but I don't quite understand what I would change as my code is a bit different to the recommendation the error gives.

Generic Snake
  • 575
  • 1
  • 5
  • 13
  • 1
    The problem is probably inside PyDictionary. They must not be providing the parser when creating the BeautifulSoup object. You may have to look insde their code to fix this. – sureshvv Feb 01 '17 at 18:49
  • 1
    See [this GitHub Issue](http://stackoverflow.com/questions/33511544/how-to-get-rid-of-beautifulsoup-user-warning) – nbryans Feb 01 '17 at 18:49
  • @nbryans I have looked at this before, but it didn't help me. I understand it spells out the issue, but in my case, what is my markup? I haven't defined any in the code. – Generic Snake Feb 01 '17 at 19:05
  • @sureshvv You might be right, but I really hope not :D. If i can't fix it, I don't think it'll matter too much if this error does appear as if i am taking output, it'll be passed elsewhere. (and will hopefully only take what I need), but I still wish it wasn't there. – Generic Snake Feb 01 '17 at 19:09
  • 1
    If it's the case that there is nothing you can do, you could always try [ignoring the warnings](http://stackoverflow.com/questions/14463277/how-to-disable-python-warnings) – nbryans Feb 01 '17 at 20:18
  • 1
    @nbryans I didn't know about this! I don't think the warning will really affect my program overall, so this is useful incase it does. Cheers. – Generic Snake Feb 01 '17 at 20:22
  • @GenericSnake... PyDictionary is on github. https://github.com/geekpradd/PyDictionary. Why not create a PR? And improve the world :) – sureshvv Feb 03 '17 at 06:42
  • @sureshvv haha, maybe, if i get the project I need it for done first :D – Generic Snake Feb 05 '17 at 03:25

1 Answers1

1

Editing the utils.py file in the PyDictionary module worked for me. You can check the error message for the location of PyDictionary/utils.py in case you're confused.

For example in this PC here the location of PyDictionary is

C:\Users\abhis\AppData\Local\Programs\Python\Python37\lib\site-packages\PyDictionary\utils.py

Fire up IDLE and make the following change.

Change line-5

return BeautifulSoup(requests.get(url).text)

To

return BeautifulSoup(requests.get(url).text, features="html.parser")

Here are the screenshots before & after the edit.