Require PyTorch dependency for reticulate when installing a package

I want to include PyTorch as a requirement for an R library using the reticulate -package.

(Another solution would be if it is installed (i.e., reticulate::py_install("PyTorch") ) when the user is using the library/function the first time, but not every time.)

I tried to add PyTorch as a dependence through the "header"/"description" of the function:

#' @importFrom reticulate PyTorch

But when I run devtools::document() I get this error:

Loading rpackageX Error in asChar(ivars) : empty name in directive 'importFrom' in 'NAMESPACE' file

Thanks in advance.

1 Like

The roxygen2 tag @importFrom is for declaring R package dependencies. Since PyTorch is a Python package, that won't work.

Here are some resources to help you decide how to handle the PyTorch dependency:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.