【问题标题】:R reticulate install python packagesR网状安装python包
【发布时间】:2020-11-04 08:50:49
【问题描述】:

我无法通过 reticulate 安装 python 包。我收到以下错误:

virtualenv_install('r-reticulate', 'numpy')

Using virtual environment 'r-reticulate' ...
Error: invalid version specification ‘’, ‘  ’
In addition: Warning messages:
1: In system2(python, c("-c", shQuote(command)), stdout = TRUE, stderr = TRUE) :
  running command ''/home/xxxxxxxxx/.virtualenvs/r-reticulate/bin/python' -c 'import sys; import pip; sys.stdout.write(pip.__version__)' 2>&1' had status 1
2: In if (idx != -1) version <- substring(version, 1, idx - 1) :
  the condition has length > 1 and only the first element will be used

我已经创建了虚拟环境,可以找到。

virtualenv_list()
[1] "r-reticulate"

任何想法如何找出问题所在?

【问题讨论】:

    标签: python r reticulate


    【解决方案1】:

    为了在 RStudio 中使用 python,我已经通过 conda 设置了环境。

    我的 R 块中的第一个:

    install.packages("reticulate")
    library(reticulate)
    

    然后还是在一个 R 块中:

    #create the r-reticulate environment
    conda_create=("r-reticulate")
    Sys.setenv(RETICULATE_PYTHON ="path where env is located")
    #Installing python libraries through conda
    conda_install("r-reticulate", "numpy") 
    

    现在在 python 脚本或块中,您可以通过以下方式正常调用库:

    import numpy
    

    【讨论】:

      猜你喜欢
      • 2019-09-22
      • 1970-01-01
      • 1970-01-01
      • 2012-07-18
      • 2021-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多