reticulate

Install python in r step by step

Create environment

library(reticulate)
conda_create(envname = 'D:/python/env/r-reticulate', python_version = '3.6.13')

Edit .Rprofile

# usethis::edit_r_profile()
# Sys.setenv(RETICULATE_PYTHON = 'D:\\python\\env\\r-reticulate\\') # version 3.6

Install python package

Default environment

my_env <- "D:\\python\\envs\\r-reticulate"

Install packages using conda

reticulate::conda_install(envname = my_env, packages = "lightgbm")

Install packages using pip

reticulate::py_install(packages = "xgboost", envname = my_env)

Extra

install miniconda if needed

reticulate::install_miniconda(path = "D:/python/")
reticulate::miniconda_update(path = "D:/python/") # update if needed

check python version

reticulate::py_version()
reticulate::py_versions_windows()

check config

reticulate::py_config() 
reticulate::py_discover_config()

check conda envs

reticulate::conda_list()
# conda_remove("pillow")
reticulate::virtualenv_list()

convert to rmd

rmarkdown:::convert_ipynb("python/volatility-prediction.ipynb")