'How to fix reticulate error in RStudio to use python?

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


Solution 1:[1]

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!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Zane Cantrell