[英]Can't install tensorflow with reticulate via conda, virtualenv, or py_install
I've been running into some reticulate
trouble when trying to use tensorflow
.在尝试使用
tensorflow
时,我遇到了一些reticulate
问题。 If I run a plain R session or plain Python session on the CLI I am able to install and use tensorflow.如果我在 CLI 上运行一个普通的 R 会话或普通的 Python 会话,我就可以安装和使用 tensorflow。
library(reticulate) # loads fine
conda_create("r-reticulate") # seems to work
conda_install("r-reticulate", "scipy") # seems to work
conda_install("r-reticulate", "tensorflow") # fails
# Collecting package metadata (current_repodata.json): ...working... done # Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve. # Solving environment: ...working... failed with repodata from current_repodata.json, will retry with next repodata source. # # ResolvePackageNotFound: # - python=3.1 # # Error: one or more Python packages failed to install [error code 1]
Not sure what that's about, so then I try不确定那是什么,所以我尝试
use_condaenv("r-reticulate") # seems to work
py_install("tensorflow") # fails
which gives the error:这给出了错误:
Error: could not find a Python environment for /opt/local/bin/python3.9
错误:找不到 /opt/local/bin/python3.9 的 Python 环境
So then I tried:然后我尝试了:
virtualenv_create("rstudio-python-virtualenv")
which throws the error抛出错误
ERROR: Failed cleaning build dir for numpy
错误:无法清除 numpy 的构建目录
Even though that failed, just for laughs I tried即使失败了,为了笑我也试过了
virtualenv_install("rstudio-python-virtualenv", "tensorflow")
which throws哪个抛出
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
错误:找不到满足张量流要求的版本(来自版本:无)
After some more troubleshooting I tried changing the Python interpreter specified in "Global Options" to these 2 new virtual environments created above.经过更多的故障排除后,我尝试将“全局选项”中指定的 Python 解释器更改为上面创建的这两个新虚拟环境。 It had no effect on the error messages.
它对错误消息没有影响。
I also tried reticulate::py_install("tensorflow")
which throws:我也尝试过
reticulate::py_install("tensorflow")
抛出:
Collecting package metadata (current_repodata.json): ...working... done Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve. Solving environment: ...working... failed with repodata from current_repodata.json, will retry with next repodata source. ResolvePackageNotFound: - python=3.1 Error: one or more Python packages failed to install [error code 1] >
Apprently at least part of the problem was that conda_create
was creating environments based on versions of Python that were too new for the version of tensorflow
it was trying to install (ie Python v3.10.0).显然,至少部分问题在于
conda_create
正在创建基于 Python 版本的环境,这些版本对于它尝试安装的tensorflow
版本(即 Python v3.10.0)来说太新了。 This worked:这有效:
conda_create("r-py-conda-3.6", python_version = "3.6")
conda_install(envname = "r-py-conda-3.6",
packages=("tensorflow"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.