Search code examples
rpandaskerasrstudioreticulate

Can't make `pandas` module available in `reticulate`


I am trying to use keras in R, and the error occurs when I am trying to call flow_images_from_dataframe():

Error in flow_images_from_dataframe() : 
  Pandas (python module) must be installed in the same environment as Keras.Install it using reticulate::virtualenv_install("pandas", envname = "r-tensorflow") or reticulate::conda_install("pandas", envname = "r-tensorflow") depending on the kind of environment you are using.

I tried the following:

reticulate::py_module_available("pandas")
# FALSE.

# checking that environment is there:
reticulate::virtualenv_list()
# "r-reticulate" "r-tensorflow"

# activate the environment:
use_virtualenv('r-tensorflow')

reticulate::virtualenv_install("pandas", envname = "r-tensorflow")
# ...
# ...
# Installing collected packages: pandas
# Successfully installed pandas-1.1.5

# Trying again:
py_module_available("pandas")
# FALSE

# The issue is specific to pandas, other modules are fine:
reticulate::py_module_available('scipy')
# TRUE

Solution

  • I still don't understand what was the problem there and why virtualenv_install() didn't do the job, but the solution that helped me was as simple as

    py_install("pandas")