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

py_install() hardwires the paths for virtualenv instead of following PATH #499

cboettig opened this issue May 12, 2019 · 1 comment


None yet
1 participant
Copy link

commented May 12, 2019

Here's a reprex:

  # fails
py_install("h5py", "/opt/venv")
#> Error: Prerequisites for installing Python packages not available.
#> Please install the following Python packages before proceeding: virtualenv
  # but this works
virtualenv_install("/opt/venv", "h5py")
#> Using virtual environment '/opt/venv' ...
  ## here's py_config:
#> python:         /opt/venv/bin/python
#> libpython:      /usr/lib/python2.7/config-x86_64-linux-gnu/
#> pythonhome:     /usr:/usr
#> virtualenv:     /opt/venv/bin/
#> version:        2.7.13 (default, Sep 26 2018, 18:42:22)  [GCC 6.3.0 20170516]
#> numpy:          /opt/venv/local/lib/python2.7/site-packages/numpy
#> numpy_version:  1.16.3
#> python versions found: 
#>  /opt/venv/bin/python
#>  /usr/bin/python
#>  /usr/bin/python3

Created on 2019-05-12 by the reprex package (v0.2.1)

Not clear to me why py_install believes virtualenv is not installed. Testing this on Debian 9 with this setup


This comment has been minimized.

Copy link

commented May 13, 2019

Digging into the reticulate code, it looks like this is due to the hardwired binary paths in reticulate:::python_unix_binary("virtualenv"), which is called by checks inside py_install() but not by virtualenv_install().

function (bin) 
    locations <- file.path(c("/usr/bin", "/usr/local/bin", path.expand("~/.local/bin")), 
    locations <- locations[file.exists(locations)]
    if (length(locations) > 0) 
    else NULL
<bytecode: 0x55f506dd6fd0>
<environment: namespace:reticulate>

Is there a reason why reticulate choses to hardwire some common unix paths while ignore PATH (and ignoring the path set with either use_virtualenv() or RETICULATE_PYTHON)? Is there a way to override this?

Also, here's sessionInfo() for reference:

#> R version 3.6.0 (2019-04-26)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Debian GNU/Linux 9 (stretch)
#> Matrix products: default
#> BLAS/LAPACK: /usr/lib/
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=C             
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> loaded via a namespace (and not attached):
#>  [1] compiler_3.6.0  magrittr_1.5    tools_3.6.0     htmltools_0.3.6
#>  [5] yaml_2.2.0      Rcpp_1.0.1      stringi_1.4.3   rmarkdown_1.12 
#>  [9] highr_0.8       knitr_1.22      stringr_1.4.0   xfun_0.6       
#> [13] digest_0.6.18   evaluate_0.13


@cboettig cboettig changed the title py_install fails to find virtualenv but virtualenv_install() works just fine py_install() hardwires the paths for virtualenv instead of following PATH May 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.