rstudio / reticulate

R Interface to Python
https://rstudio.github.io/reticulate
Apache License 2.0
1.68k stars 328 forks source link

Request / Suggestion: repl_python() Use IPython by Default #749

Open jtelleriar opened 4 years ago

jtelleriar commented 4 years ago

When using repl_python() for executing Python Code, it is executed by using a regular Python Interpreter, unless you specify a specific IPython Executable.

However, would it be possible to enable IPython Interpreter by default?

By doing so, users will be able to benefit for %magic commands, for example, in order to explore python variables which have been created through the %whos magic command.

Thanks!

jtelleriar commented 4 years ago

Also mention that I get an error when I try to manually start the IPython Terminal:

Sys.setenv(
  RETICULATE_PYTHON = "C:/Users/J-tel/.conda/envs/conda_env_name/Scripts/ipython3.exe"
)

library(reticulate)

repl_python()

Error in py_initialize(config$python, config$libpython, config$pythonhome, : python37.dll - No se puede encontrar el módulo especificado.

:(

jooyoungseo commented 1 year ago

@kevinushey -- I cannot change the default repl to ipython on Windows. Is this an intended behavior?

kevinushey commented 1 year ago

IIRC, we don't yet support the use of an IPython interpreter from within reticulate, but I believe @t-kalinowski has done some investigation here.

The REPL started by repl_python() is implemented and provided by reticulate directly, since we need to support some of R's idiosyncrasies in console input / output.

t-kalinowski commented 1 year ago

I did some investigations in this direction a while back. As part of that, there is an unexported proof-of-concept that you can use in the Terminal with reticulate.

#  reticulate::py_install("IPython")
reticulate:::ipython()

Note that the above works as expected in a Terminal, but using it to drive the REPL in the RStudio IDE Console mostly doesn't work. There are just certain assumption that IPython makes about the terminal it's running in that are not true in the Console. Overall, we recommend using repl_python().

t-kalinowski commented 1 year ago

Note also that repl_python() has support for some %magic commands, similar to IPython. See ?repl_python for details.