Error: Unable to find conda binary. Is Anaconda installed?

家住魔仙堡 提交于 2021-02-11 15:44:29

问题


I am trying to run python scripts in R. I have a macOS Catalina 10.15.4 and I continue to receive this error:

"Error in value[[3L]](cond) : 
  Need to install Anaconda from https://www.anaconda.com/download/.
Error: Unable to find conda binary. Is Anaconda installed?"

I have already downloaded python 3.8 and I have already downloaded anaconda. After exhausting Google searches. I'm learning that the path for my conda might be the issue. Google searches then recommend using "use_condaenv()" to specify the correct path, but I still receive the same error: Error: Unable to find conda binary. Is Anaconda installed?"

In short: How do I find the correct location of my binary conda? How do I correct the path accurately? How to I resolve the error?

Here is the syntax I've ran so far:

install.packages("reticulate")

library(reticulate)

repl_python()

Python 2.7.16 (/usr/bin/python)

Reticulate 1.13 REPL -- A Python interpreter in R.

reticulate::py_config()

python:         /usr/bin/python
libpython:      /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome:     /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version:        2.7.16 (default, Feb 29 2020, 01:55:37)  [GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc-
numpy:          /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version:  1.8.0

python versions found: 
 /usr/bin/python
 /usr/bin/python3
 /usr/local/bin/python3

use_python("/usr/bin/python3", required = TRUE)

**ERROR: The requested version of Python ('/usr/bin/python3') cannot be used, as another version of
Python ('/usr/bin/python') has already been initialized. Please restart the R session if you need
to attach reticulate to a different version of Python.
Error in use_python("/usr/bin/python3", required = TRUE) : 
  failed to initialize requested version of Python**

Sys.which("python")

           python 
"/usr/bin/python" 

install.packages("youtubecaption")

library(youtubecaption)

**The downloaded binary packages are in
    /var/folders/n2/kl03cmjj04n5msjq8x8mt_yr0000gn/T//RtmpD82WW0/downloaded_packages**

url<-"https://www.youtube.com/watch?v=qATvD6kQ47s&t=339s" #this is just an example url#

caption<-get_caption(url)

**Error in value[[3L]](cond) : 
  Need to install Anaconda from https://www.anaconda.com/download/.
Error: Unable to find conda binary. Is Anaconda installed?**

回答1:


Here are three different things you can try.

RETICULATE_PYTHON environment variable

Reticulate also searches for an environment variable RETICULATE_PYTHON, where you can define the python you want to use. Define here.

Sys.setenv(RETICULATE_PYTHON = "path/to/anaconda/bin/python")
library(reticulate)
# and so on

reticulate.conda_binary option

reticulate has an option to specify the conda executable (define here). Can you try this?

options(reticulate.conda_binary = "path/to/bin/conda")
library(reticulate)

PATH environment variable

You can also try setting your PATH variable within R to include your anaconda/bin directory:

# Prepend the anaconda/bin directory so that python installation 
# is found before any others.
original_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste("path/to/anaconda/bin", original_path, sep = ":"))

library(reticulate)
reticulate::py_config()
# and so on


来源:https://stackoverflow.com/questions/60974507/error-unable-to-find-conda-binary-is-anaconda-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!