My shinyapp uses reticulate because one of my library use some python function.
I keep getting "Error detecting python for reticulate".
I tried everything I have seen in other posts on the subject like:
use_python(python = "C:/Anaconda3",required = FALSE)
py_available(initialize = TRUE)
[1] TRUE
setting the RETICULATE_PYTHON environment... but in vain, always getting this error
And of course trying to use an old rsconnect package with the famous:
devtools::install_github("rstudio/rsconnect",ref='737cd48')
With this last command I got (after many minutes):
Preparing to deploy application...DONE
Uploading bundle for application: 983472...DONE
Deploying bundle: 2158207 for application: 983472 ...
Waiting for task: 623011556
building: Processing bundle: 2158207
building: Parsing manifest
building: Building image: 2275583
building: Installing system dependencies
building: Fetching packages
building: Building package: RUnit
building: Building package: RSpectra
building: Building package: quantreg
curl: (56) Send failure: Connection was aborted
Error in http(service$protocol, service$host, service$port, method, url, :
Curl request failed (curl error 56 occurred)
Calls: ... isContentType -> grepl -> GET -> httpRequest -> http
Execution halted
It's a pity because I have to go for another solution after more than one month of hard work...
This path doesn't exist in shinyapps.io server, have in minde that the published app is going to run in a system other than yours, try with something like this:
library(reticulate)
# Create a virtual environment selecting your desired python version
virtualenv_create(envname = "python_environment", python= "python3")
# Explicitly install python libraries that you want to use, e.g. pandas, numpy
virtualenv_install("python_environment", packages = c('pandas','numpy')
# Select the virtual environment
use_virtualenv("python_environment", required = TRUE)
@andresrcs: First I want to say thanks for this post. Like the original post, I tried many solutions and spent hours researching how to get reticulate to work when publishing my app to shinyapps.io. Your post was very straightforward and I think finally made it click. I followed your suggestion and included similar code inside the app file. It seemed to work because I no longer get the error "Did you forget to set the RETICULATE_PYTHON environment variable in your .Rprofile before publishing?". However, I now get a different error. In the log output below it shows that the virtual environment is being created, and pandas and numpy are being installed successfully, but when the call is made to import pandas, it returns an error saying there is no module pandas.
Do you have any thoughts on why this might be happening?
Thanks.
Log output:
Creating virtual environment 'DataGen_shiny_env' ...
Using python: python3
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/shiny/.virtualenvs/DataGen_shiny_env/bin/python3
Also creating executable in /home/shiny/.virtualenvs/DataGen_shiny_env/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
Requirement already up-to-date: pip in /home/shiny/.virtualenvs/DataGen_shiny_env/lib/python3.5/site-packages (20.1.1)
Requirement already up-to-date: wheel in /home/shiny/.virtualenvs/DataGen_shiny_env/lib/python3.5/site-packages (0.34.2)
Requirement already up-to-date: setuptools in /home/shiny/.virtualenvs/DataGen_shiny_env/lib/python3.5/site-packages (46.4.0)
Using virtual environment 'DataGen_shiny_env' ...
Collecting pandas
Downloading pandas-0.24.2-cp35-cp35m-manylinux1_x86_64.whl (10.0 MB)
Collecting numpy
Downloading numpy-1.18.4-cp35-cp35m-manylinux1_x86_64.whl (20.0 MB)
Collecting python-dateutil>=2.5.0
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting pytz>=2011k
Downloading pytz-2020.1-py2.py3-none-any.whl (510 kB)
Requirement already satisfied, skipping upgrade: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.5.0->pandas) (1.10.0)
Installing collected packages: python-dateutil, pytz, numpy, pandas
Listening on ...
Successfully installed numpy-1.18.4 pandas-0.24.2 python-dateutil-2.8.1 pytz-2020.1
Warning: Error in py_call_impl: ImportError: No module named 'pandas'