knitr, reticulate and rstudio : Problem with figure labelling ?

I had a quite frustrating time setting up Rstudio dev Version 1.4.1714 on a new PC / windows yesterday - (I am using the dev version due to this bug, but the problem appears also with 1.3.1390 version.
I am stuck due to the following problem : python chunks produce figures that are all labelled with the same label. Does anyone met this problem yet ?

Here is a Rmarkdown example to reproduce this problem on my PC

---
output:
  pdf_document: default
  html_document: default
---

```{r setup, include=FALSE}
library(reticulate)
```

```{python}
import matplotlib.pyplot as plt
plt.plot([1,2])
```

```{r}
x<-2
``` 
```{python}
plt.plot([7,8])
```

Output on my machine is

Note that two figures were created but the second plot erased the first. While generating the latex, one can see that the same reference is created for both figures.

EDIT: I just found a workaround. It seems that the problem came with the newer reticulate version 1.20. Thus the workaround is : reverse to reticulate version 1.16 :
remove.packages("reticulate")
require(devtools)
install_version("reticulate", version = "1.16")

Did you open an issue in the reticulate repo ? This would be useful if this is a regression.

Hello, no I did not, because it is hard to know whether the problem come from reticulate or rmarkdown. But you are right, I will add an link to this post to reticulate repo, since RMarkdown users might be stuck into this reticulate version 1.16.

Thanks.

Reticulate is a good place to start as you said installing previous version fixed the issue. If this is rmarkdown or knitr we will move the issue in the correct repo afterwards.

Thank you !

Bug report added here, hoping this is the right place to report it !

1 Like

For reference, this has now been fixed in reticulate current dev version

1 Like