-
-
Notifications
You must be signed in to change notification settings - Fork 979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loading python package via reticulate fails with rmarkdown::render
whereas Rscript
succeeds
#2542
Comments
Do you have access to the intermediate Rmd created ? Are you able to use the import inside a Rmd document using Reticulate ? or more generally the conda environment ? Either using the python engine (https://rstudio.github.io/reticulate/articles/r_markdown.html) or regular R chunk with reticulate code ? RScript will run the R script directly. I don't have mamba, nor conda, so I would need to setup an environment to reproduce. Installing ---
title: "Test"
date: "`r Sys.Date()`"
output: html_document
---
```{r}
scanpy <- reticulate::import('scanpy', convert=TRUE)
```
Running also this simple R scripts works for me (with scanpy <- reticulate::import('scanpy', convert=TRUE) So it seems to be related to some reticulate configuration, or interaction in R Markdown context, when using Conda env possibly. Not easy to debug... If you are able to build something like a Docker Image or dev container config that reproduce this, this will help us. Or even a GH action. Otherwise, I'll see if I can setup an environment to reproduce. |
hi, |
Is the issue only happening inside RStudio IDE ? What happens if you run the
Error seems to happen in
If you manage to do one, then I'll be able to look on my side too. This would help a lot! |
hi thanks again! So far I didn't find any good debug / verbose options for reticulate, and I'm still struggling to set up a Docker image with conda env installed ... |
Thanks for the additional information. I don't think knitr or rmarkdown is doing anything with This is some type of annoying bug that require to be reproduced so that several people can look into it. If docker itself is not easy, maybe setting up a devcontainer configuration will be easier. I see there is specification for Anaconda available (https://github.com/devcontainers/images/tree/main/src/anaconda) Dev container works well locally in VSCODE and also only in CODESPACE. Maybe this starter template can help ? The Rocker project also has some devcontainer recipes specific for R and R package
Maybe with this, it can be a little bit easier than doing DOCKERFILE from scratch. Hope it helps |
Hi,
I'm trying to run python packages via reticulate, but imports fail when using
rmarkdown::render("script.R")
whereasRscript script.R
succeeds.here's my conda env
here's my script
test_env.R
here's the output of
Rscript test_env.R
:and here's the result of
Rscript -e "library(rmarkdown); rmarkdown::render('test_env.R','html_document')"
:uncommenting the
reticulate::import
line gives the exact same logs, so library paths etc. should all be identical as far as I can seeit's somehow related to
libjpeg-turbo
, but I can't figure out why there's a difference between theRscript
and thermarkdown::render
calls.sessionInfo
Checklist
When filing a bug report, please check the boxes below to confirm that you have provided us with the information we need. Have you:
formatted your issue so it is easier for us to read?
included a minimal, self-contained, and reproducible example?
pasted the output from
xfun::session_info('rmarkdown')
in your issue?upgraded all your packages to their latest versions (including your versions of R, the RStudio IDE, and relevant R packages)?
installed and tested your bug with the development version of the rmarkdown package using
remotes::install_github("rstudio/rmarkdown")
?The text was updated successfully, but these errors were encountered: