Open potrbollvy opened 2 years ago
I've tested it a bit more, and it seems that the issue is when I try to print/display the soup (wakefieldBS
). If I use "Run Current Chunk" or if I run from the Python "shell", I don't need to call print()
to display the soup, but if I run from bookdown, I do.
Seems fairly conclusive that it's not a reticulate issue, then.
Hello, I am encountering a problem while using reticulate in bookdown, but I am not sure if this is a reticulate issue or a bookdown issue (or just a programming issue on my part, more likely?). I've snooped around online and the error message I get seems to be associated with reticulate, but I don't understand Python/the package enough to dig in deeper.
I am attempting to use Beautiful Soup to parse an HTML document. I can run the following code directly from RStudio without problems:
{r} library(reticulate)
{python} from bs4 import BeautifulSoup
from urllib.request import urlopen
wakefieldURL = 'https://www.theweathernetwork.com/ca/weather/quebec/wakefield' wakefieldHTML = urlopen(wakefieldURL) wakefieldBS = BeautifulSoup(wakefieldHTML, 'html.parser')
wakefieldBS
(by this I mean that I can "Run Current Chunk" in the RStudio script window and the code behaves as it should). This yields the parsed HTML document found at the URL above (too large to paste here). I can also run the code from the RStudio command prompt (after having entered what I imagine would be called a Python "shell").
When I try to run it in bookdown, however, I get the following error message:
Error message:
Error in value$
_reprhtml() : attempt to apply non-function
Calls: local ... engine -> <Anonymous> -> eng_python_autoprint -> as_r_value
I should note that I am able to use reticulate in bookdown without any problems for "regular" things like:
{r} library(reticulate)
{python} import math math.cos( math.sqrt( math.pi ) )
Is this an actual issue with reticulate, or with Beautiful Soup, or am I barking up the wrong tree?
Thanks,
P
PS: I can't get the {r} and {python} bits to format properly here, but I'm using the "```" notation for bookdown.