错误:找不到conda二进制文件.是否安装了Anaconda? [英] Error: Unable to find conda binary. Is Anaconda installed?

查看:209
本文介绍了错误:找不到conda二进制文件.是否安装了Anaconda?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在R中运行python脚本.我有一个macOS Catalina 10.15.4,并且我继续收到此错误:

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?"

我已经下载了python 3.8,并且已经下载了anaconda.用完Google搜索之后.我得知我的conda路径可能是问题.然后,Google搜索建议使用"use_condaenv()"来指定正确的路径,但我仍然收到相同的错误:错误:无法找到conda二进制文件.是否安装了Anaconda?"

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?"

简而言之:如何找到二进制conda的正确位置?如何正确校正路径?如何解决该错误?

这是我到目前为止运行的语法:

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?**

推荐答案

您可以尝试以下三种方法.

Here are three different things you can try.

Reticulate还会搜索环境变量 RETICULATE_PYTHON ,您可以在其中定义要使用的python.在此处定义.

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 选项

reticulate 具有指定conda可执行文件的选项(定义此处).你可以试试吗?


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 环境变量

您还可以尝试在R中设置您的 PATH 变量以包含您的 anaconda/bin 目录:


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

这篇关于错误:找不到conda二进制文件.是否安装了Anaconda?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆