python - 错误:无法找到 conda 二进制文件。Anaconda 安装了吗?
问题描述
我正在尝试在 R 中运行 python 脚本。我有一个 macOS Catalina 10.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?"
我已经下载了 python 3.8 并且我已经下载了 anaconda。用尽谷歌搜索后。我正在学习我的 conda 的路径可能是问题所在。谷歌搜索然后建议使用“use_condaenv()”来指定正确的路径,但我仍然收到相同的错误:错误:无法找到 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?**
解决方案
您可以尝试以下三种不同的方法。
RETICULATE_PYTHON
环境变量
Reticulate 还搜索环境变量RETICULATE_PYTHON
,您可以在其中定义要使用的 python。在这里定义。
Sys.setenv(RETICULATE_PYTHON = "path/to/anaconda/bin/python")
library(reticulate)
# and so on
reticulate.conda_binary
选项
reticulate
可以选择指定 conda 可执行文件(在此处定义)。你能试试这个吗?
options(reticulate.conda_binary = "path/to/bin/conda")
library(reticulate)
PATH
环境变量
您还可以尝试PATH
在 R 中设置变量以包含您的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 on
推荐阅读
- python - 如果 dict 键的值在 otherlist 中,则从列表中的 dicts 中删除元素
- ag-grid - 如何在 Ag-grid angular 中扩展分组数据中的行?
- javascript - 为什么 RTCMultiConnection 事件类型总是“本地”?
- laravel - 在 usersController 中调用 Laravel 资源时给了我不同的路径和错误
- haskell - Traversable 对 Applicative 上下文意味着什么?
- android - 找不到库依赖项
- python - Dictionay `__getitem__` 多下标覆盖
- javascript - 如何轻松更改上下文?
- database - 我有一个关于 VoltDB 的问题。(外键约束)
- google-apps-script - EffectiveUser 电子邮件为空的情况