gpt4 book ai didi

python - R中的Python-错误: could not find a Python environment for/usr/bin/python

转载 作者:行者123 更新时间:2023-12-03 13:45:32 29 4
gpt4 key购买 nike

我不明白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。
我这是怎么了?

最佳答案

尝试按照https://tensorflow.rstudio.com/installation/的指南进行操作:
在您的R-studio控制台中:

  • install.packages(tensorflow)
  • library(tensorflow)
  • install_tensorflow()

  • 如果您尚未手动安装Anaconda/Miniconda,则请执行步骤no。 3,提示将询问您的许可以安装Miniconda。如果您已经安装了 conda,则:
  • 在conda中创建新环境r-reticulate:conda create -n r-reticulate
  • 从R-studio控制台安装带有参数的tensorflow:install_tensorflow(method = 'conda', envname = 'r-reticulate')
  • 加载网状软件包library(reticulate)
  • 在R-studio中激活conda环境use_condaenv('r-reticulate')
  • 加载 tensorflow libray library(tensorflow)
  • 检查tensorflow是否处于 Activity 状态tf$constant("Hellow Tensorflow")

  • 引用 :
  • https://tensorflow.rstudio.com/installation/
  • https://rstudio.github.io/reticulate/
  • 关于python - R中的Python-错误: could not find a Python environment for/usr/bin/python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63220597/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com