-
Notifications
You must be signed in to change notification settings - Fork 326
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
.globals$py_config is not updated when changing conda environment #1147
Comments
.globals$py_config is now updated by initialize_python when it is equal to null or not equal to .globals$required_python_version.
I have forked the project and added Now
However in the miniconda terminal the package can be spotted. This means that still not the correct conda environment is used.
|
changes required due to issues caused in: rstudio/reticulate#1147
Hi @t-kalinowski, please any response? |
Hi, apologies for the taking so long to respond. I'm not quite sure I understand the issue. Changing When reticulate is first loaded, |
@t-kalinowski Thanks a lot for your reply, much appreciated! The issue occurs if you want to use two conda environments the default environment In that case To workaround this you need to install all packages in the default environment While reading your response I was starting to get the (maybe wrong) impression that making a custom conda environment for an r package becomes useless as this cannot be used. Hope this clarifies it a bit. It is indeed a complex issue. If my explanation is still lacking clarity please let me know! |
I think that when you are writing an R package that uses reticulate, you can aim for convenience by hooking into reticulate::configure_environment, and/or by calling In the tensorflow ecosystem we like to provide a In all cases though, once reticulate's Python session is initialized and bound to one Python, it cannot then initialize another Python. If you absolutely need to use only one Python conda environment in your R package, then you would need to raise an error if "wrong" Python is already initialized. |
Many thanks for your insightful reply! I have written an The reason that I am advocating for using conda or venv is that I am very afraid of python package version dependency issues inside the user's default python session, this can possibly lead to all kind of unexpected behavior inside my r package which is very hard to predict and to check for in unit tests. In my eyes having a shielded python environment would be highly desirable. I would like to end with the fact that reticulate is an amazing package which allows me to run many python packages inside r. Thanks a lot for this package. |
in accordance with rstudio/reticulate#1147
Hi @kevinushey and @t-kalinowski,
I am working on an r-package and I want to use a specific miniconda python environment in the r package.
I notice however that after I use
reticulate::use_miniconda(condaenv = "r-eikon", required = T)
the internal global package value.globals$required_python_version
is updated to the r-eikon conda environment but the value of.globals$py_config
is left at the old conda environment (r-reticulate).This leads to very weird behavior. E.g. when calling
reticulate::py_module_available
will return that already installed python modules are not available. However when opening miniconda and runningconda activate r-eikon
andconda list
these are shown as installed in the r-eikon environment.A possible solution for this would be to again initialize_python as currently it is only initialized once and when changing environments it is not initialized again.
reticulate/R/package.R
Lines 29 to 56 in da51570
So maybe in
use_python()
after the following line:reticulate/R/use_python.R
Line 112 in 1523ef5
When there is a difference between
.globals$required_python_version
and.globals$py_config
to add something analogue to this:
.globals$py_config <- initialize_python(some variables)
Reproducible bug:
The text was updated successfully, but these errors were encountered: