Search code examples
pythonrreticulate

Install a particular version of python package in a virtualenv created with reticulate


When using reticulate package in order to use Python inside R, we can create a virtualenv thanks to the command reticulate::virtualenv_create specifying env name and the path to the python bin.

We can also add packages to the previously created environment like this:

  reticulate::virtualenv_create(envname = 'venv_shiny_app',
                                 python = '/usr/bin/python3')
  reticulate::virtualenv_install('venv_shiny_app',
                                 packages = c('numpy',
                                              'xlrd',
                                              'pandas',
                                              'beautifulsoup4',
                                              'joblib'))

Is it possible to install a specific version of those packages??

Thanks


Solution

  • You can request a specific version of a package with, for example:

    reticulate::virtualenv_install(packages = c("numpy==1.8.0"))