Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
leungi opened this issue Sep 1, 2019 · 3 comments
Open

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

leungi opened this issue Sep 1, 2019 · 3 comments

Comments

@leungi
Copy link

leungi commented Sep 1, 2019

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
Copy link
Owner

mkearney commented Sep 4, 2019

@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
Copy link
Author

leungi commented Sep 4, 2019

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
Copy link

alabarca commented Aug 4, 2020

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
#>�[38;5;246m# A tibble: 0 x 0�[39m
#>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`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants