Problem installing python libraries with reticulate::py_install() - Error pip: not found

Hi everyone,
I have tried to install python libraries from R using the reticulate::py_install() function for the first time (I usually use pip3 from a system terminal) and I'm getting this error.

#> Using virtual environment 'r-reticulate' ...
#> sh: 1: /home/andres/.virtualenvs/r-reticulate/bin/pip: not found
#> Error: Error installing package(s): 'pip'
#> Warning in system2(pip, args): error in running command

Does any one have experienced a similar problem? python3 uses pip3 instead of pip, do I have to specify this somewhere?

I'm using RStudio Server 1.2.1329 and here is my

#> R version 3.5.3 (2019-03-11)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 18.04.2 LTS
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas/
#> LAPACK: /usr/lib/x86_64-linux-gnu/
#> locale:
#>  [1] LC_CTYPE=es_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=es_US.UTF-8        LC_COLLATE=es_US.UTF-8    
#>  [5] LC_MONETARY=es_US.UTF-8    LC_MESSAGES=es_US.UTF-8   
#>  [7] LC_PAPER=es_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> 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] Rcpp_1.0.1      lattice_0.20-38 ps_1.3.0        withr_2.1.2     digest_0.6.18   R6_2.4.0       
#> [7] grid_3.5.3      jsonlite_1.6    reprex_0.2.1    evaluate_0.13   rlang_0.3.1     fs_1.2.6       
#> [13] callr_3.2.0     whisker_0.3-2   Matrix_1.2-16   rmarkdown_1.12  tools_3.5.3     processx_3.3.0 
#> [19] xfun_0.5        compiler_3.5.3  clipr_0.5.0     htmltools_0.3.6 knitr_1.22

I found an explanation and a solution, the default environment for reticulate is "r-reticulate", but for some reason it doesn't like the default python2 version of ubuntu 18 server "Python 2.7.15rc1" this is why I'm getting that error message.

If I want to use python3, I have to create a virtual environment for python3, preferably with a system() call but also works with virtualenv_create() although it throws some warnings when installing python libraries with this method.

system("virtualenv -p /usr/bin/python3 /home/andres/.virtualenvs/py3-virtualenv")
# Also works with this
#virtualenv_create("py3-virtualenv", python = "/usr/bin/python3")
py_install("pandas", envname = "py3-virtualenv")

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.