我试图在R中运行python脚本,我有一个macOS Catalina10.15.4,并且继续收到这个错误:
"Error in value[[3L]](cond) :
Need to install Anaconda from https://www.anaconda.com/download/.
Error: Unable to find conda binary. Is Anaconda installed?"我已经下载了python3.8和anaconda。在用尽谷歌搜索之后。我知道我的康达之路可能是问题所在。然后谷歌搜索推荐使用"use_condaenv()“来指定正确的路径,但我仍然会收到相同的错误: error:无法找到conda二进制文件。Anaconda安装了吗?“
简而言之:,如何找到二进制conda的正确位置?我如何准确地纠正这条路?如何解决错误?
下面是我到目前为止运行的语法:
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?**发布于 2020-04-01 15:44:30
这里有三件不同的事情你可以尝试。
RETICULATE_PYTHON环境变量
Reticulate还搜索环境变量RETICULATE_PYTHON,您可以在其中定义要使用的python。定义这里。
Sys.setenv(RETICULATE_PYTHON = "path/to/anaconda/bin/python")
library(reticulate)
# and so onreticulate.conda_binary选项
reticulate有一个选项来指定conda可执行文件(定义这里)。你能试试这个吗?
options(reticulate.conda_binary = "path/to/bin/conda")
library(reticulate)PATH环境变量
还可以尝试在R中设置PATH变量以包括anaconda/bin目录:
# 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 onhttps://stackoverflow.com/questions/60974507
复制相似问题