简体   繁体   中英

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

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM