R session aborted after reticulate::py_config

I have followed the instruction here https://support.rstudio.com/hc/en-us/articles/360023654474-Installing-and-Configuring-Python-with-RStudio and here https://docs.rstudio.com/tutorials/user/using-python-with-rstudio-and-reticulate/.

I followed the same steps earlier this year, and it worked. However, today, RStudio IDE crashes and aborted after I run

library(reticulate)
reticulate::py_config()

Restart RStudio IDE

reticulate::py_config()

then, RStudio crashes

NOTES:

Other codes that I used before to configure python (environment, package installation) are as following

C:\Users\drkim>where python
C:\Users\drkim\Anaconda3\python.exe
C:\Users\drkim\AppData\Local\Microsoft\WindowsApps\python.exe

C:\Users\drkim>where conda
C:\Users\drkim\Anaconda3\Library\bin\conda.bat
C:\Users\drkim\Anaconda3\Scripts\conda.exe

C:\Users\drkim>cd C:\PythonR

C:\PythonR>virtualenv .env
created virtual environment CPython3.7.4.final.0-64 in 1062ms
  creator CPython3Windows(dest=C:\PythonR\.env, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\drkim\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

C:\PythonR>C:\PythonR\.env\Scripts\activate

(.env) C:\PythonR>pip install numpy
Collecting numpy
  Using cached numpy-1.19.1-cp37-cp37m-win_amd64.whl (12.9 MB)
Installing collected packages: numpy
Successfully installed numpy-1.19.1

(.env) C:\PythonR>

What should I do to rectify this?

Hey,

you should change the RETICULATE_PYTHON, to the binaries necessary to run python

From your log, I would say that you need to point to C:\Users\drkim\Anaconda3\python.exe

And from your screenshot, I would replace in the .Rprofile file to:

Sys.setenv(RETICULATE_PYTHON = "C:\Users\drkim\Anaconda3\python.exe")

The .Rprofile could be unrelated, but it caught my attention that this variable is not pointed to the executable.

Hi,

Thank you. I can confirm that your solution works but that solution will use python environment outside my working directory. My main objective by using the function Sys.setenv() is to take the advantage of python environment (created using the virtualenv function) that sits inside the current project directory.

You can watch this at minute 6 from this link https://docs.rstudio.com/tutorials/user/using-python-with-rstudio-and-reticulate/

Regards,

KIM

I sent an issue to github and the developer has fixed it. You can see it here https://github.com/rstudio/reticulate/issues/827 . It works for me.

I need to do this
library(devtools)
install_github("rstudio/reticulate")

2 Likes

If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.