sti*_*neb 6 python r keras tensorflow reticulate
我不明白 R 如何处理 Python 环境和 Python 版本并不断收到错误Error: could not find a Python environment for /usr/bin/python。我安装了 Miniconda 并在 shell 中创建了一个 conda 环境:
conda activate r-reticulate
Run Code Online (Sandbox Code Playgroud)
然后,在 R 中,我尝试安装 keras(与包 tensorflow 相同的问题):
library(keras)
reticulate::use_condaenv()
install_keras(method = "conda", conda = reticulate::conda_binary())
Run Code Online (Sandbox Code Playgroud)
...并得到以下错误:
Error: could not find a Python environment for /usr/bin/python
Run Code Online (Sandbox Code Playgroud)
我试图弄清楚 Python R 应该使用什么
reticulate::py_config()
Run Code Online (Sandbox Code Playgroud)
并得到
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, Jul 5 2020, 02:24:03) [GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.21) (-macos10.15-objc-
numpy: /Users/bestocke/Library/Python/2.7/lib/python/site-packages/numpy
numpy_version: 1.16.6
tensorflow: [NOT FOUND]
python versions found:
/usr/bin/python3
/usr/local/bin/python3
/usr/bin/python
Run Code Online (Sandbox Code Playgroud)
我不明白这个。这似乎是使用 Python 2.7。当试图找出 shell 中正在使用哪个 Python 时,我得到:
> which python
/opt/miniconda3/envs/r-reticulate/bin/python
Run Code Online (Sandbox Code Playgroud)
和
> ls -l /opt/miniconda3/envs/r-reticulate/bin/python
lrwxr-xr-x 1 username wheel 9 Aug 2 15:21 /opt/miniconda3/envs/r-reticulate/bin/python -> python3.6
Run Code Online (Sandbox Code Playgroud)
建议使用 Python 3.6。
我在这里出了什么问题?
Anu*_*aut 19
尝试按照https://tensorflow.rstudio.com/installation/ 上的指南进行操作:
在您的 R-studio 控制台中:
install.packages(tensorflow)
library(tensorflow)
install_tensorflow()
如果您尚未手动安装 Anaconda / Miniconda,则在步骤 no. 3、提示会询问您是否允许安装Miniconda。如果您已经conda安装,则:
r-reticulate在 conda 中创建新环境:conda create -n r-reticulateinstall_tensorflow(method = 'conda', envname = 'r-reticulate')library(reticulate)use_condaenv('r-reticulate')library(tensorflow)tf$constant("Hellow Tensorflow")参考 :
| 归档时间: |
|
| 查看次数: |
8708 次 |
| 最近记录: |