Using Pipenv with R Markdown and reticulate

R Markdown is very nice way to write literate R code. Recently, reticulate became available, which bridges R and Python in R Markdown documents.

If you use Pipenv for Python dependency management, here's how you get reticulate to use the proper Python executable:

library('reticulate')
venv <- system("pipenv --venv", inter = TRUE)
use_virtualenv(venv, required = TRUE)
py_config()

The py_config() command should print out the path to the Python executable in the virtualenv created by Pipenv.


🌟 Was this page helpful? Please let me know with this quick, 3 question survey.

2 responses
could you help me, I have error for `system("pipenv --venv", inter = TRUE)` as `sh: pipenv: command not found`
@Kilometer0101: looks like the pipenv executable isn’t available on the shell R is using. Probably some issue with your $PATH.