-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Regression in Python reticulate discovery within a project #11195
Comments
On additional review, I don't believe this to be a regression; it seems to be expected behavior, and I have provided the reporting user with multiple ways for them to achieve their desired behavior here. |
Maybe we want to change the behavior of inferred python so we specifically check for virtualenv named r-reticulate/WORKON_HOME, and set RETICULATE_PYTHON_FALLBACK to that before selecting system python |
The way we guess / set the version is probably worth a blog post |
I just ran into this surprise, where reticulate binds to a different Python in the IDE vs the terminal (because the IDE sets What is the reasoning behind setting I'm eager also to hear if there are changes I can make in reticulate to simplify this, or align what we're doing in the IDE with what happens outside the IDE. Overall the "guess which python" reticulate behavior feels unpredictable, even without the IDE in the mix. |
@kevinushey probably has more historical context around this situation, but here is my rough understanding. Firstly, I believe that the We used to infer it and set this to That said I don't fully understand why and how we choose to infer a specific version of Python (I can point to where in the code that happens, but can't necessarily speak to design decisions around it). I'm interested in more discussion around what would be the ideal user experience, and what you would expect to happen if a user selected "Automatically activate project-local Python environments" and hasn't specifically requested a particular python with |
I definitely agree this is worthy of some kind of article... |
As I recall, the primary goal here was to ensure the version of Python available in an RStudio terminal, and the version of Python that reticulate would bind to (or is already bound to), are the same. The The extra challenge here is that we wanted this all to succeed without forcing the Perhaps we should instead do something like:
The other slightly-related task is to ensure that the version of Python that RStudio has been configured to use (via global or project preferences) is also communicated to reticulate. That preference should take precedence over most of reticulate's auto-discovery machinery, but There's also the added requirement that the version of Python used during the render of an R Markdown document (by reticulate) is the same as configured in the current session, as well as in deployments. A lot of moving parts here! |
Apologies, I don't fully understand: What exactly is checking the global option "Python > Automatically activate project-local Python environments" supposed to do? Follow-up question: is that something reticulate should do by default? (…and we remove the option from the IDE? Or maybe help users set |
|
An alternative to setting setHook(packageEvent("reticulate", "onLoad"),
function(...) {
try(reticulate::use_virtualenv("project-env", required = TRUE))
})
That makes perfect sense! Maybe the description should include the word "Terminal" to make that clearer. Or maybe the option should migrate to the "Terminal" options pane. |
For reference, we're doing something similar here: rstudio/src/cpp/session/modules/SessionReticulate.R Lines 117 to 130 in 9ab60a7
|
This occurs simply because RStudio tries to infer which version of Python the user wishes to use when the user has not explicitly specified a Python interpreter. The user can easily specify that they wish to use a virtual env Python by running |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry for the previous message. User error--I had a stray |
Opening a new issue based on @salim-b 's report on previously closed #9990
I did not follow all the issues/PRs related to all the recent Python discovery changes. But I think I've just stumbled upon a serious regression:
Setup details
rstudio-2022.06.0-daily-394-amd64
on Ubuntu 22.04WORKON_HOME=/home/salim/.by_pkg_mngr/virtualenvwrapper
, then created the virtualenvr-reticulate
(default name) usingreticulate::virtualenv_create()
and finally installed the Python packageplotly
in it usingreticulate::virtualenv_install(packages = "plotly")
.RETICULATE_PYTHON
norRETICULATE_PYTHON_FALLBACK
.Problem description
If I open any RStudio project, trying to discover the proper python location fails:
But when I open an RStudio session that is not associated with a project, my virtualenv
r-reticulate
is properly detected:It's also properly detected by running
Rscript -e 'reticulate::py_discover_config(required_module = "plotly")'
from a terminal.This looks like a clear regression to me since the same reticulate setup on stable RStudio 2022.02.2+485 on Ubuntu 20.04 detects the virtualenv in both cases. My guess would be that this regression was introduced with #10518, thus pinging @kevinushey @jgutman
Originally posted by @salim-b in #9990 (comment)
The text was updated successfully, but these errors were encountered: