rstudio / reticulate

R Interface to Python
https://rstudio.github.io/reticulate
Apache License 2.0
1.66k stars 327 forks source link

Haven't been able to get the `Config/reticulate` feature work #703

Open nturaga opened 4 years ago

nturaga commented 4 years ago

Hi @kevinushey

I'm trying to use the new features in reticulate https://github.com/nturaga/BiocDockerManager/blob/reticulate_failure/DESCRIPTION#L23-L28 within my package.

My understanding of the feature is, that as long as I have (the block of code below) in my DESCRIPTION file, reticulate will do the right thing and install miniconda if needed OR start a new conda environment if with the name r-reticulate if conda already exists. Please correct my understanding if this not accurate.

Config/reticulate:
  list(
    packages = list(
      list(package = "docker")
    )
  )

But somehow, this functionality doesn't get triggered at all. My reticulate py_config() shows the following,

> py_config()
python:         /usr/bin/python
libpython:      /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome:     /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version:        2.7.16 (default, Oct 16 2019, 00:34:56)  [GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)]
numpy:          /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version:  1.8.0

python versions found:
 /usr/bin/python
 /Users/nturaga/miniconda3/envs/hail/bin/python
 /Users/nturaga/miniconda3/envs/octave/bin/python
 /Users/nturaga/miniconda3/envs/spark-test/bin/python
 /Users/nturaga/miniconda3/bin/python

As you can see, I already have an installation of conda on my system. I'm trying to use this on a Mac. My R sessionInfo() is

> sessionInfo()
R Under development (unstable) (2019-11-25 r77460)
Platform: x86_64-apple-darwin18.7.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /Users/nturaga/R-stuff/bin/R-devel/lib/libRblas.dylib
LAPACK: /Users/nturaga/R-stuff/bin/R-devel/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] reticulate_1.14-9001

loaded via a namespace (and not attached):
[1] compiler_4.0.0  Matrix_1.2-18   rappdirs_0.3.1  Rcpp_1.0.3
[5] grid_4.0.0      jsonlite_1.6    lattice_0.20-38
kevinushey commented 4 years ago

The output from py_config() shows that you've activated the system version of Python, as opposed to your Miniconda environment. You have to use use_condaenv() or similar to make sure reticulate binds to the appropriate version of Python.

Note that this machinery should only activate when using a Python environment (virtualenv or condaenv).