【发布时间】:2020-11-22 23:57:33
【问题描述】:
我不明白 R 如何处理 Python 环境和 Python 版本,并不断收到错误 Error: could not find a Python environment for /usr/bin/python。我安装了 Miniconda 并在 shell 中创建了一个 conda 环境:
conda activate r-reticulate
然后,在 R 中,我尝试安装 keras(与包 tensorflow 相同的问题):
library(keras)
reticulate::use_condaenv()
install_keras(method = "conda", conda = reticulate::conda_binary())
...并得到以下错误:
Error: could not find a Python environment for /usr/bin/python
我试图弄清楚 Python 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, 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
我不明白这一点。这似乎使用的是 Python 2.7。当试图弄清楚 shell 中使用了哪个 Python 时,我得到:
> which python
/opt/miniconda3/envs/r-reticulate/bin/python
和
> 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
建议使用 Python 3.6。
我在这里做错了什么?
【问题讨论】:
标签: python r tensorflow keras reticulate