python in r: pandas not found

2.6k views Asked by At

I am trying to improve my research by the combining of R and Python advantages. Reticulate package is a promising tool for this purpose. But something comes wrong...

devtools::install_github("rstudio/reticulate")
library(reticulate)

py_available()

[1] FALSE

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.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

numpy: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy numpy_version: 1.8.1

python versions found:

/usr/bin/python

/usr/local/bin/python

/usr/local/bin/python3

/Users/User/anaconda/bin/python

use_python(" /Users/User/anaconda/bin/python")

I am using all "data science pack" under Anaconda. Thet is why the corresponded python version was chosen. All required packages are installed and they often in use via Jupiter notebook

py_available() 

[1] TRUE

Yes, as expected!

py_module_available("pandas")

[1] FALSE

Not available for some reason(((

Thank you in advance for the ideas))

SessionInfo for a case:

R version 3.4.1 (2017-06-30) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.6

Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

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

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

other attached packages: [1] reticulate_1.1.0.9004

loaded via a namespace (and not attached): [1] httr_1.3.1 compiler_3.4.1 R6_2.2.2 tools_3.4.1 withr_2.0.0 curl_2.8.1 memoise_1.1.0
[8] Rcpp_0.12.12 git2r_0.19.0 digest_0.6.12 jsonlite_1.5 devtools_1.13.3

2

There are 2 answers

0
Moises Diaz On

You need to set the second argument of the function, so it should be:

For expample use_python("/users/my_user/Anaconda3/python.exe",required = TRUE)

DONT forget the required = TRUE

0
Dan Tasse On

I think you have to call use_python immediately after calling library(reticulate), before py_config or anything else.

That worked for me. More details in this question: Importing python module in R