Hi All,
I’m encountering an issue deploying my rgee-based Shiny app. Locally, everything works perfectly, but once deployed, the app seems to default to the system Python (/usr/bin/python3) instead of using a virtual environment built from my requirements.txt.
As a result, essential packages like numpy and earthengine-api aren’t available, and Earth Engine fails to initialize non?interactively.
Can get app to deploy fine if EE aspects are removed but that limits required functionality.
Details:
Environment:
rgee version: 1.1.7 (CRAN release)
reticulate, Shiny, and other packages are up-to-date.
I’m deploying on [ShinyApps.io/Posit Connect]
requirements.txt (in the project root):
numpy
earthengine-api
google-auth
google-api-python-client
Credentials:
I’m using a service account key (a valid JSON file with all required fields) located in my project under a credentials folder. I set the environment variable with:
Sys.setenv(GOOGLE_APPLICATION_CREDENTIALS = "credentials/credentials.json") but also tried google cloud console credentials file.
App Initialization Code:
Clear the console
cat("\014")
Load required packages for app - that runs locally
library(rgee)
library(reticulate)
library(shiny)
library(leaflet)
library(DT)
library(dplyr)
library(writexl)
library(ausplotsR)
library(shinyjs)
library(shinycssloaders)
library(zip)
library(ggplot2)
library(plotly)
library(httr)
library(zoo)
library(forecast)
library(tidyr)
Set service account credentials (relative path)
Sys.setenv(GOOGLE_APPLICATION_CREDENTIALS = "credentials/credentials.json")
(Optional) Print debugging info
print(reticulate::py_config())
print(reticulate::py_module_available("numpy"))
print(reticulate::py_list_packages())
Initialize Earth Engine (should use credentials and the virtualenv built from requirements.txt)
ee_Initialize(drive = FALSE, gcs = FALSE)
Logs:
The logs show that the Python environment used is still:
python: /usr/bin/python3
...
numpy: [NOT FOUND]
ee: [NOT FOUND]
NOTE: Python version was forced by RETICULATE_PYTHON
I’ve removed any forced RETICULATE_PYTHON settings in the code and relied solely on the requirements.txt file for dependency management. Despite this the build logs indicate that the system Python is being used, so my app never picks up numpy or earthengine-api.
Has anyone encountered this issue? Any advice on ensuring that the virtual environment built from requirements.txt is used (or on how to force the correct environment) would be greatly appreciated.
Many thanks.
Kind regards,
Chris