mkearney / googler

googler: Google from the R Console
Other
14 stars 2 forks source link

googler() with default arguments fails, but otherwise works #2

Open leungi opened 5 years ago

leungi commented 5 years ago

Reprex below.

I tried looking at source code, but can't find where the default arguments are set.


Sys.setenv("RETICULATE_PYTHON" = "C:\\Users\\leungi\\AppData\\Local\\Continuum\\anaconda3\\python.exe")
reticulate::py_config()
#> python:         C:\Users\leungi\AppData\Local\Continuum\anaconda3\python.exe
#> libpython:      C:/Users/leungi/AppData/Local/Continuum/anaconda3/python37.dll
#> pythonhome:     C:\Users\leungi\AppData\Local\CONTIN~1\ANACON~1
#> version:        3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
#> Architecture:   64bit
#> numpy:          C:\Users\leungi\AppData\Local\CONTIN~1\ANACON~1\lib\site-packages\numpy
#> numpy_version:  1.16.4
#> 
#> NOTE: Python version was forced by RETICULATE_PYTHON

library(googler)

## works
googler("rstats", count = 2, lang = "en")
#> # A tibble: 2 x 4
#>   abstract                      matches    title           url             
#>   <chr>                         <list>     <chr>           <chr>           
#> 1 "5h ago @akesslerdc tweeted:~ <df[,2] [~ News about #rs~ https://twitter~
#> 2 The R Project for Statistica~ <NULL>     The R Project ~ https://www.r-p~

## works
googler("rstats", count = 2)
#> # A tibble: 2 x 4
#>   abstract                       matches    title         url              
#>   <chr>                          <list>     <chr>         <chr>            
#> 1 "5h ago @akesslerdc tweeted: ~ <df[,2] [~ News about #~ https://twitter.~
#> 2 Read writing about Rstats in ~ <df[,2] [~ Rstats – Tow~ https://towardsd~

## fails
googler("rstats")
#> Warning in system2(cmd, args = args, stdout = TRUE): running command
#> '"C:\Users\leungi\AppData\Local\Continuum\anaconda3\python.exe" C:
#> \Users\leungi\AppData\Local\Temp\RtmpEVevEU/googler "rstats" -C --json' had
#> status 1
#> Error: lexical error: invalid char in json text.
#>                                        NA
#>                      (right here) ------^

Created on 2019-09-01 by the reprex package (v0.2.1)

mkearney commented 5 years ago

@leungi: would you be willing to re-install and try that code again? I made a number of changes, so although I cannot pinpoint exactly what caused this problem, I do think it has been resolved–I've done fairly extensive testing on Macs and Ubuntu Linux. But I'll wait to close this issue until I get confirmation from someone else.

leungi commented 5 years ago

Just installed latest; new error message 😅

Almost like users need to specify at minimum 2 arguments to work.

Sys.setenv("RETICULATE_PYTHON" = "C:\\Users\\leungi\\AppData\\Local\\Continuum\\anaconda3\\python.exe")
reticulate::py_config()
#> python:         C:\Users\leungi\AppData\Local\Continuum\anaconda3\python.exe
#> libpython:      C:/Users/leungi/AppData/Local/Continuum/anaconda3/python37.dll
#> pythonhome:     C:\Users\leungi\AppData\Local\CONTIN~1\ANACON~1
#> version:        3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)]
#> Architecture:   64bit
#> numpy:          C:\Users\leungi\AppData\Local\CONTIN~1\ANACON~1\lib\site-packages\numpy
#> numpy_version:  1.16.4
#> 
#> NOTE: Python version was forced by RETICULATE_PYTHON

library(googler)

## works
googler("rstats", count = 2, lang = "en")
#> # A tibble: 2 x 4
#>   abstract                       matches    title         url              
#>   <chr>                          <list>     <chr>         <chr>            
#> 1 Would you like to make report~ <df[,2] [~ #rstats hash~ https://twitter.~
#> 2 The latest Tweets from Rstats~ <df[,2] [~ Rstats (@rst~ https://twitter.~

## works
googler("rstats", count = 2)
#> # A tibble: 2 x 4
#>   abstract                       matches    title         url              
#>   <chr>                          <list>     <chr>         <chr>            
#> 1 Would you like to make report~ <df[,2] [~ #rstats hash~ https://twitter.~
#> 2 The latest Tweets from Rstats~ <df[,2] [~ Rstats (@rst~ https://twitter.~

## fails
googler("rstats", lang = "en")
#> Warning in system2(cmd, args = args, stdout = TRUE): running command
#> '"C:\Users\leungi\AppData\Local\Continuum\anaconda3\python.exe" C:
#> \Users\leungi\AppData\Local\Temp\Rtmp0Y2biK/googler "rstats" --lang en -C
#> --json' had status 1
#> # A tibble: 0 x 0

## fails
googler("rstats")
#> Warning in system2(cmd, args = args, stdout = TRUE): running command
#> '"C:\Users\leungi\AppData\Local\Continuum\anaconda3\python.exe" C:
#> \Users\leungi\AppData\Local\Temp\Rtmp0Y2biK/googler "rstats" -C --json' had
#> status 1
#> # A tibble: 0 x 0

sessionInfo()
#> R version 3.5.1 (2018-07-02)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17134)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] googler_0.0.1
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.2.1           knitr_1.24.4           magrittr_1.5          
#>  [4] lattice_0.20-38        rlang_0.4.0            fansi_0.4.0           
#>  [7] stringr_1.4.0          highr_0.8              tools_3.5.1           
#> [10] grid_3.5.1             xfun_0.9               utf8_1.1.4            
#> [13] cli_1.1.0              htmltools_0.3.6        assertthat_0.2.1      
#> [16] yaml_2.2.0             digest_0.6.20          tibble_2.1.3          
#> [19] crayon_1.3.4           Matrix_1.2-17          vctrs_0.2.0.9001      
#> [22] zeallot_0.1.0          evaluate_0.14          rmarkdown_1.15        
#> [25] stringi_1.4.3          compiler_3.5.1         pillar_1.4.2          
#> [28] backports_1.1.4        reticulate_1.13.0-9000 jsonlite_1.6          
#> [31] pkgconfig_2.0.2
alabarca commented 4 years ago

Hi! I install the last version but It isn't running:

`Sys.setenv("RETICULATE_PYTHON" = "C:\ProgramData\Anaconda3\python.exe") reticulate::py_config()

>python: C:/ProgramData/Anaconda3/python.exe

>libpython: C:/ProgramData/Anaconda3/python37.dll

>pythonhome: C:/ProgramData/Anaconda3

>version: 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)]

>Architecture: 64bit

>numpy: C:/ProgramData/Anaconda3/Lib/site-packages/numpy

>numpy_version: 1.15.4

>NOTE: Python version was forced by RETICULATE_PYTHON

googler("rstats", count = 2, lang = "en")

fails

># A tibble: 0 x 0

>Warning message:

>In system2(cmd, args = args, stdout = TRUE) :

>running command '"C:\Users\alaba\AppData\Local\Microsoft\WindowsApps\python3.exe" #C:\Users\alaba\AppData\Local\Temp\RtmpqKqJBC/googler "rstats" --count 2 --lang en -C --json' had status 9009`