Miniconda
, Python
, and Matlab
(experimental) EnvironmentThe goal of rpymat
is to create a single isolated
Miniconda
and Python
environment for
reproducible pipeline scripts. The package is a shell of
reticulate
package, but provides more stable behaviors,
especially on ‘ARM’ machines.
You can install the released version of rpymat from CRAN with:
install.packages("rpymat")
Configure python after installation
# change `python_ver` accordingly
::configure_conda(python_ver = 'auto') rpymat
Add Python
or conda
packages
# Add conda packages
::add_packages(c('pandas', 'numpy'))
rpymat
# Add conda packages from channels
::add_packages(c('h5py'), channel = "conda-forge")
rpymat
# Add pip packages
::add_packages(c('sklearn'), pip = TRUE) rpymat
Jupyterlab
# Install Jupyterlab, will install
# numpy, h5py, matplotlib, pandas,
# jupyter, jupyterlab, jupyterlab-git, ipywidgets, jupyter-server-proxy
# jupyterlab_latex, jupyterlab_github, matlab_kernel
::add_jupyter()
rpymat
# Launch Jupyterlab
::jupyter_launch(async = FALSE) rpymat
# Async option is only available in RStudio >= 1.4
<- rstudioapi::isAvailable(version_needed = "1.4")
async
::jupyter_launch(
rpymatasync = async, workdir = "~",
port = 18888, open_browser = TRUE,
token = "IwontTellYouMyToken"
)
To query existing servers
::jupyter_server_list()
rpymat#> host port token
#> 1 127.0.0.1 8888 3hzWfGPa0EOmonaNS48jrTvpw07KiX7VKerA9ZTFJMkCOJMgfB
#> 2 127.0.0.1 18888 IwontTellYouMyToken
To stop a server
::jupyter_server_stop(port = 18888) rpymat
rpymat
with
reticulate
# Initialize the isolated environment
::ensure_rpymat()
rpymat
::repl_python() reticulate
Then run python code interactively.
Alternatively, you can use rpymat::run_script(path)
to
execute Python
scripts, and use reticulate::py
to obtain the results.
The following command will erase the environment completely.
::remove_conda() rpymat