0

我在使用 R Studio 中的网状库做最基本的事情时都遇到了麻烦。我的代码如下所示:

library(reticulate)
use_python("C:\\Users\\User2017\\AppData\\Local\\Programs\\Python\\Python36\\python.exe")
 req <- import("requests")

最后一行我得到一个错误

parse error: trailing garbage
          2017\\Documents\\.condarc" } Using Anaconda Cloud api site h
                     (right here) ------^

我怎样才能得到这个工作?例如,使用 requests ,所有其他包都会失败。我将网状包指向的python 是系统范围的python,它已经安装了各种包。

我运行 sessionInfo() 的规格:

R version 3.5.3 (2019-03-11)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C                       LC_TIME=English_Australia.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reticulate_1.11.1

loaded via a namespace (and not attached):
[1] compiler_3.5.3  Matrix_1.2-15   tools_3.5.3     yaml_2.2.0      Rcpp_1.0.1      grid_3.5.3      jsonlite_1.6   
[8] lattice_0.20-38
4

1 回答 1

2

我这边也有同样的问题:

pandas <- import("pandas") 
Error: parse error: trailing garbage
      Documents\\.condarc" } Using Anaconda Cloud api site h
                 (right here) ------^

我已按照 smci 的建议:从我的计算机中删除 Anaconda 并重新链接到另一个 python 安装后,问题消失了:

use_python("~/Python36/python")
os <- import("os")

希望有帮助!

新增:Python 2.7.11、Anaconda2 4.0.0 64 位

于 2019-04-05T16:29:01.610 回答