I'm trying to make reticulate work, but am not able to use the correct venv or python version.
- I'm running RStudio-connect on an AWS EC2 instance--have had no problems with this for Rmd and shiny apps.
- Installed python 3.7.4 from source, as suggested, into
/opt/Python/3.7.4/bin/python3
. - to the rstudio-connect.gcfg file added:
[Python]
Enabled = true
Executable = /opt/Python/3.7.4/bin/python3
and restarted rstudio-connect.
-
On my local machine (a MacBook pro) I have--following suggested best practices--set up a virtual environment in the directory for my project. Within this I have installed
pandas
,numpy
andboto3
. -
At the top of the app I've loaded the necessary packages (
shiny
,reticulate
), then referenced my virtual environment:use_virtualenv("./my_venv", required=TRUE)
.
When I publish this to rs-connect, I get the error message:
ERROR: The requested version of Python
('/opt/rstudio-connect/mnt/app/venv/bin/python') cannot be used, as
another version of Python ('/usr/bin/python3') has already been
initialized. Please restart the R session if you need to attach
reticulate to a different version of Python.
Can someone tell me how else I can "attach reticulate to a different version of Python"? I've already called Sys.setenv(RETICULATE_PYTHON = "/opt/Python/3.7.4/bin/python3")
before loading reticulate
.
Also, when I start R on the command line of the RStudio-connect server and enter reticulate::py_discover_config()
I get:
python: /usr/bin/python3
libpython: /usr/lib/python3.6/config-3.6m-x86_64-linux-gnu/libpython3.6.so
pythonhome: /usr:/usr
version: 3.6.8 (default, Jan 14 2019, 11:02:34) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
numpy: /usr/local/lib/python3.6/dist-packages/numpy
numpy_version: 1.17.2
python versions found:
/usr/bin/python
/usr/bin/python3
which would seem to indicate that the executable being specified in the .gcfg
file is being ignored.
Thank for any pointers--looking forward to getting this working.