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

Change path to Python binary #27

Closed
jannes-m opened this issue Mar 21, 2017 · 9 comments
Closed

Change path to Python binary #27

jannes-m opened this issue Mar 21, 2017 · 9 comments

Comments

@jannes-m
Copy link

@jannes-m jannes-m commented Mar 21, 2017

Dear reticulate-developers,

thanks for developing such a fantastic package!

Is it possible to change the path to another Python binary after already having run py_config or py_run_string?
In my case I would like to point reticulate to the QGIS Python binary (which is a bit of a hazzle under Windows). This works, i.e. reticulate accepts the QGIS Python binary (mostly to be found under C:\OSGEO4~1\bin\python.exe).

However, before running any RQGIS function I would like to check if the correct Python binary is in use. Assuming, the user has not set up correctly the QGIS Python environment, running py_config might point to another Python binary such as Anaconda Python ("...\AppData\Local\CONTIN1\ANACON1\python.exe). In this case, I would like to change to the QGIS Python binary. I tried use_python but it didn't work. Or is there any other way to find out which Python binary reticulate would use at a specific moment but without actually setting it.

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Mar 21, 2017

I agree that it would be good to have a "preview" of what the reticulate binding will be. I'll try to add that to the next version. In the meantime you can add the required = TRUE flag to use_python to fail with an error if it can't find the version specified.

Loading

@jannes-m
Copy link
Author

@jannes-m jannes-m commented Mar 23, 2017

Thanks for the answer! Until the "preview"-option becomes available, I will use a simple work-around.

I hope you don't mind another related question. Is it also possible to close (and then again to restart) the connection to Python? This would be rather useful. So far, I always restart R to achieve this.

Loading

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Mar 23, 2017

Loading

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Mar 24, 2017

Just exported the py_discover_config function here: 4118c57

Loading

@jjallaire jjallaire closed this Mar 24, 2017
@jannes-m
Copy link
Author

@jannes-m jannes-m commented Apr 9, 2017

Thanks for py_discover_config!

Loading

@mxposed
Copy link

@mxposed mxposed commented Jul 16, 2019

@jjallaire could you please elaborate on why is it not possible to close established python session? I think it would be a nice feature to be able to re-initialize python with another binary (version or virtualenv) without restarting R session

Loading

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Jul 17, 2019

Loading

@mxposed
Copy link

@mxposed mxposed commented Jul 17, 2019

Thank you for the explanation. Is it theoretically possible to initialize python in a forked process and then kill one if there is a need for reload? But I guess the communication would become a lot more complex

Loading

@jjallaire
Copy link
Member

@jjallaire jjallaire commented Jul 17, 2019

Loading

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

Successfully merging a pull request may close this issue.

None yet
3 participants