rstudio / tensorflow.rstudio.com

https://tensorflow.rstudio.com
9 stars 12 forks source link

Control where the Virtual Environment is created #66

Closed sreedta8 closed 7 months ago

sreedta8 commented 11 months ago

Hi

I'm experimenting with "reticulate" and tensorflow & keras ecosystem for the first time. I have used R for 20+ years and Python by itself via Anaconda, but not integrated the two together. One of the reasons, of course, is to use the DL tools such as TF and Keras from R. I would like to know how I can specify the creation of virtual environments in a location other than that what is chosen by default by the "install_keras()" function.

The problem I run into is that for some of my colleagues at work, the default is an online Documents folder (MS One Drive) and the virtual environments are being created online and there is no way to use any of the DL functionality as the constant error is "No TensorFlow installation found" or some to that effect. Could I control where the virtual env is created, say for example under, "c:/users/batman/.virtualenv/joker/"?

t-kalinowski commented 11 months ago

There are a few ways:

Or you can set it a .Renviron file

WORKON_HOME=~/../.virtualenvs

E.g.,:

cat(sprintf("\nWORKON_HOME='%s'\n", normalizePath("~/../.virtualenvs", "/")),
           file = "~/.Renviron", append = TRUE))

Or you can set it in a .Rprofile, or in an R session directly:

Sys.setenv(WORKON_HOME = "~/../.virtualenvs")
sreedta8 commented 11 months ago

@t-kalinowski Thank you!!!!! I know I cannot set through System Variables option. Good to know I can use multiple options to set via R