Closed astamm closed 5 months ago
Hi, thanks for raising the issue.
Python version "3.12" just came out earlier this month, so this is a new issue.
That said, install_tensorflow()
already has logic that will constrain the python version, and select the oldest suitable version installed on the machine. E.g., if you have called
lapply(sprintf("%s:latest", c("3.8", "3.9", "3.10", "3.11", "3.12")),
reticulate::install_python))
And then:
tensorflow::install_tensorflow()
Then the r-tensorflow
venv should be created with Python version 3.9
.
You can also directly specify the python version desired via
tensorflow::install_tensorflow(python_version = "3.9")
Or:
tensorflow::install_tensorflow(python_version = ">=3.9,<=3.11")
Or:
tensorflow::install_tensorflow(python_version = "3.9,3.10,3.11")
Or even:
tensorflow::install_tensorflow(python_version = "/path/to/venv/starter/bin/python")
Thanks for the quick reply! I indeed circumvented the issue by running
tensorflow::install_tensorflow(python_version = "3.9")
However I believe it could be nice to have it set by default even without running first
lapply(sprintf("%s:latest", c("3.8", "3.9", "3.10", "3.11", "3.12")),
reticulate::install_python))
Hi,
Just want to add that I've come across a similar issue in getting this to install properly on a share HPC system. By default, even after trying setting up ~/.Renviron
, reticulate's use_python()
, or Sys.setenv(RETICULATE_PYTHON="/path/to/bin/python")
, the install_tensorflow()
command would default to the latest python version available on path.
The only way to circumvent this was by specifying within the command like so:
install_tensorflow(python_version = "/path/to/bin/python")
RETICULATE_PYTHON
is for telling reticulate which python to bind to in the current R session, not for selecting which python to use as a venv starter when creating a new python installation.
If you're in an environment where there are already a few python versions installed and available, and reticulate::virtualenv_starter()
is not finding them, you can set the env var
RETICULATE_VIRTUALENV_STARTER=paths
or the R options(reticulate.virtualenv.starter = paths)
, where paths is :
separated string of paths under which (potentially) multiple python versions can be found.
Thanks for clarifying! This information was lacking from the RStudio TensorFlow install and custom install pages. As you clarified, the custom install page only describes specifying the python version that reticulate binds to the R session.
Since it is explicitly recommending running install_tensorflow()
, I think it's assumed the python version reticulate binds will be used to create venvs. Not totally sure why that is not the default case?
Probably a question for the folks at reticulate...
Thanks for the suggestion! This is now implemented in the dev version of reticulate - virtualenv_starter()
will consult RETICULATE_PYTHON
and use_python()
when assembling the list of candidate python's for creating a venv.
IIUC, the first time one wants to use R {tensorflow}, he is expected to run once
install_tensorflow()
which installs Python {tensorflow} in virtual environmentr-tensorflow
.However, by default, the tf version is 2.14 (latest) which runs on Python 3.9-3.11 and the default python version is 3.12, hence resulting in tensorflow not being found (either via pip or via conda-forge).
I am running macOS Ventura 13.6, M1 ARM64, but I believe it is not an OS issue. I believe
install_tensorflow()
should default to using Python 3.11.