3

I am receiving an error when trying to use reticulate that says

library(reticulate)
library(tidyverse)
library(janitor)

Sys.setenv(RETICULATE_PYTHON = "C:/Users/Menu/Programs/Python 3.10.exe")

My Python 3.10 is located in C:/Users/Menu/Programs/Python 3.10.exe

Error in system2(command = python, args = shQuote(config_script), stdout = TRUE,  : 
  '""C:/Users/Menu/Programs/Python 3.10.exe""' not found

When I type in the command prompt:

>>>where python.
C:\Users\AppData\Local\Microsoft\WindowsApps\python.exe
Zane Cantrell
  • 247
  • 3
  • 9
  • So have you tried the obvious? `Sys.setenv(RETICULATE_PYTHON = "C:\Users\AppData\Local\Microsoft\WindowsApps\python.exe")` I admit that as a Linux user I can never keep straight how Windows handles its directory separators. So maybe use: C:/Users/AppData/Local/Microsoft/WindowsApps/python.exe which is what it might be on a Linux box. – IRTFM Apr 06 '22 at 23:50
  • Yes I tried that and it gives the same error. It is weird because I have python installed on my computer. – Zane Cantrell Apr 06 '22 at 23:57

2 Answers2

6

I am answering my own question. I was able to figure out how to find the correct path that wasn't showing up in my cmd for some reason.

Type this in R:

reticulate::conda_list()

It will print out all the paths that conda is listed.

Output:

name                                                    python
1 r-miniconda C:\\Users\\AppData\\Local\\r-miniconda\\python.exe
2   anaconda3                   C:\\Users\\anaconda3\\python.exe

Then I added the following

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

It worked!

Zane Cantrell
  • 247
  • 3
  • 9
  • 1
    Bravo. I like this sort of self answered question. Even better would be to cite the resources with links used to come up with this strategy: Specific help pages? Tutorials? Installation manuals? – IRTFM Apr 07 '22 at 00:35
0

I have the same kind of problem, however the trick does not work for me:

> library(reticulate)
Error in Sys.setenv(PATH = new_path) : wrong length for argument
In addition: Warning message:
package ‘reticulate’ was built under R version 4.0.5
> conda_list()
name                                 python
1 base C:\\Program Files\\python39/python.exe

Then I restarted R and did the following

Sys.setenv(RETICULATE_PYTHON = "C:\\Program Files\\python39/python.exe")
library(reticulate)

which was followed by the same error message.

Any help would be appreciated.

Cheers Renger

arnyeinstein
  • 669
  • 1
  • 5
  • 14
  • Do you have Anaconda Navigator installed on your machine? Try installing anaconda then using python.exe inside of conda. – Zane Cantrell Jun 13 '22 at 15:55
  • No, I have a Python 3.9 installed by the departement. I can't install programms on my own. – arnyeinstein Jun 29 '22 at 19:22
  • I had that same issue. I had to submit a ticket with IT to upgrade. – Zane Cantrell Jun 29 '22 at 23:10
  • Unfortunately, that is not an option here. We are stuck with this version another year. – arnyeinstein Jul 03 '22 at 18:06
  • Try setting python instead of conda_list(): ```use_python("C:\\Program Files\\python39/python.exe") ``` Documentation:https://rstudio.github.io/reticulate/articles/versions.html#:~:text=To%20set%20the%20value%20of,is%20your%20preferred%20Python%20binary. – Zane Cantrell Jul 06 '22 at 18:56
  • I got the same error message: reticulate::use_python("C:\\Program Files\\python39\\python.exe") Error in Sys.setenv(PATH = new_path) : wrong length for argument – arnyeinstein Jul 08 '22 at 08:21