I can't install gekko package via R reticulate. My R version is 3.4.4 and my Python version is 3.8.8 and I use Gekko in Python without problems. So I tried to install on R in these two ways I know:
py_install("gekko")
reticulate::conda_install("my_conda_environment", "gekko")
However in both cases I receive the same error bellow.
PackagesNotFoundError: The following packages are not available from current channels:
Current channels:
I didn't find other alternatives in the Anaconda documentation. How can I fix this?
Edit: I solved my problem based on the references in John Hedengren's answer and reticulate docs. For that, I needed to create a new environment to specify the Python version and packages using the following code in R:
reticulate::py_install(
packages = c(
"numpy",
"pandas", # Or another packages that you need
"gekko"
),
envname = "r-gekko",
method = "conda", # On Windows, the 'conda' method is always used
python_version = "3.8.8",
pip = TRUE # It's mandatory to install gekko
)
A more general answer for help in similar cases:
reticulate::py_install(
packages = c(
"gekko",
"other_package==x.x.x", # It's possible to specify the package version
...
),
envname = "new_env",
method = "conda", # For Windows
python_version = "3.x.x",
pip = TRUE
)
Sys.setenv(RETICULATE_PYTHON = "/Users/user_name/anaconda#/envs/new_env/python.exe")
library(reticulate)
source_python("path/script.py")