Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompting user input #1644

Open
khharut opened this issue Aug 10, 2024 · 5 comments
Open

Prompting user input #1644

khharut opened this issue Aug 10, 2024 · 5 comments

Comments

@khharut
Copy link

khharut commented Aug 10, 2024

permission <- utils::askYesNo(sprintf(

Please remove this logic. In case of non-interactive session initialization of python for most cases would fail, even if there are Python installed on the OS.

@t-kalinowski
Copy link
Member

That code is only executed in interactive sessions. See just one line above

reticulate/R/config.R

Lines 475 to 476 in d683b3b

if (is_interactive()) {
permission <- utils::askYesNo(sprintf(

What is the problem or error you are encountering?
Please avoid spamming multiple issue.

@khharut
Copy link
Author

khharut commented Aug 10, 2024

Hi, thanks for quick response. The problem is that I have OS python and I do not want any virtual python environment at all. And each time when I restart R session and executing: reticulate::py_available(initialize = TRUE), I have to answer question "Would you like to create a default Python environment for the %s package?", since each time I am saying "No". Don't you think it is annoying? I have found a solution:

Sys.setenv(RETICULATE_AUTOCREATE_PACKAGE_VENV = 0)
reticulate::py_available(initialize = TRUE).

But I do not like it either, since I have to deal with some unknown environment variable.

Therefore I am asking please change the logic. It is very strange behavior and I spent whole day understanding it.

@khharut
Copy link
Author

khharut commented Aug 10, 2024

And about other issue, I think it is not related to this directly. Any environment variable must be well-documented and has solid use case. Otherwise, one can invent as much as he wants and that will over-complicate the code. And because of that, I am asking please please remove that environment variable. Thanks again.

@t-kalinowski
Copy link
Member

If you have a strong preference for which Python you want reticulate to use, I suggest setting the environment variable RETICULATE_PYTHON to the path to the Python executable. e.g., in .bashrc or .bash_profile or .Renviron,

export RETICULATE_PYTHON=/usr/bin/python

Or in .Rprofile

Sys.setenv("RETICULATE_PYTHON" = "/usr/bin/python")

I agree that reticulate should remember if the user declined to create the venv and not ask again.

That said, the default is the default because it leads to the most consistently positive experience for users. Defaulting to the system python leads to problems when you begin installing packages - it often results to a very broken installation with no easy way to revert to a working state, especially for novices to Python installation management.

I encourage you to accept the prompt and let reticulate default to using the r-reticualte venv.

You may also want to look at the "Order of Discovery" to understand how reticualte selects a Python installation to bind to. https://rstudio.github.io/reticulate/articles/versions.html#order-of-discovery

@khharut
Copy link
Author

khharut commented Aug 11, 2024

Hi,

let me do not accept with such a workaround. You again try to convince me that environment variable is a good approach. And one has to define environment variable $A or $B to make a module work as it is intended to work. Again, I think makes very hard to follow the idea for new user. Why just do not add a new parameter to a function? It is more easy to implement and easy to document. And environment variable definition depends on OS and sometimes one has to restart server to make them work. And defining environment variables for Windows OS is really nightmare.

My idea is simple. Just add a new parameter to skip creating mandatory python virtual environment and remove some useless environment variables. Usage of environment variable must be exceptional, only for the cases when other approaches do not work at all.

Thank you for your time and readiness to help.

Regards,
Harutyun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants