Questions tagged [reticulate]

Usage questions regarding reticulate R package which provides a comprehensive set of tools for interoperability between Python and R.

Questions on the reticulate R package which provides a comprehensive set of tools for interopability between Python and R. More information on tutorials and API reference can be found on reticulate's website.

486 questions
39
votes
11 answers

Unable to change Python path in reticulate

The first lines I run when launching my rstudio session are: library(reticulate) use_python("/usr/local/lib/python3.6/site-packages") However, when I run py_config() it shows as still using the default python 2.7 installation. This is an issue…
hackerman
  • 1,221
  • 3
  • 17
  • 38
17
votes
3 answers

Reticulate - Running python chunks in Rmarkdown

Maybe I'm missing something, but if the following code is the content of my Rmd file ```{r} library(reticulate) use_virtualenv("r-reticulate") py_available(TRUE) ``` ```{python} a = 7 print(a) ``` ```{r} py$a ``` when I Knit the file, the output…
VFreguglia
  • 2,129
  • 4
  • 14
  • 35
16
votes
3 answers

reticulate ImportError: No module named pandas in Rstudio version 1.2

I am trying to use the reticulate package in a Rmd file. I first created a setup chunk as follows: library(reticulate) use_virtualenv("r-reticulate") use_python("C:\\Python27") Then I import pandas: #importing libraries import pandas …
umair durrani
  • 5,597
  • 8
  • 45
  • 85
14
votes
3 answers

Python in R - Error: could not find a Python environment for /usr/bin/python

I don't understand how R handles the Python environment and Python version and keep getting the error Error: could not find a Python environment for /usr/bin/python. I installed Miniconda and created a conda environment in the shell: conda activate…
stineb
  • 461
  • 1
  • 5
  • 11
12
votes
2 answers

pyomo + reticulate error 6 the handle is invalid

I'm trying to run a pyomo optimization and I get the error message [Error 6] The handle is invalid. Not sure how to interpret it, looking around it seems to have something to do with privileges but I don't really understand it. Find below the…
lrnzcig
  • 3,868
  • 4
  • 36
  • 50
11
votes
1 answer

Running the R package reticulate in Docker environment

In a previous work, I used the 'reticulate' package to run the Autogluon autoML library in R. The code works well in my current configuration (Ubuntu 20.4, R 4.10, reticulate v. 125). However, this code doesn't work in Docker. Dockerfile FROM…
11
votes
3 answers

R reticulate unable to find installed python library

I'm venturing into using Reticulate in R and having trouble installing a package, specifically psycopg2 but I've also tried installing twisted with the same result. after I load reticulate in R I double check to make sure my package is installed: >…
JD Long
  • 59,675
  • 58
  • 202
  • 294
11
votes
2 answers

Reticulate not sharing state between R/Python cells or Python/Python cells in RMarkdown

I'm trying to get Reticulate working in RMarkdown, per the setup instructions. However, I am unable to share state between separate Python cells or Python and R cells, as the docs indicate I should be able to. Here is my setup and output: Cell 1…
Sean Cochran
  • 171
  • 6
11
votes
1 answer

R reticulate, how do I clear a python object from memory?

I've created a function using some python functionality via the reticulate package, specifically opening an image using PIL: image <- "~/Desktop/image.jpg" pil.image <- reticulate::import( "PIL.Image", convert = FALSE ) img <- pil.image$open( image…
rosscova
  • 5,430
  • 1
  • 22
  • 35
10
votes
2 answers

Conda reports PackagesNotFoundError: python=3.1 for reticulate environment

I'm trying to use python packages in R, but I keep getting the same error: ImportError: cannot import name 'read_csv' from 'pandas' (unknown location) I cant use "py_install" neither: Collecting package metadata (current_repodata.json):…
hideonbush
  • 149
  • 1
  • 10
10
votes
3 answers

Can't figure out how to use conda environment after reticulate::use_condaenv(path)

I created a conda environment using the terminal: conda create --name pathfinder_example_proj_env python=3.6 feather-format=0.4.0 statsmodels=0.9.0 I also created a trivial python script import feather import pandas as pd import statsmodels.api as…
Brad Cannell
  • 3,020
  • 2
  • 23
  • 39
9
votes
2 answers

reticulate doesn't print to console in real time

Using Python's print() (or to the best of my knowledge, any other console output generating) function in loop structures and running the code via reticulate in R, the output is only printed after the execution finished. For example, take the…
fdetsch
  • 5,239
  • 3
  • 30
  • 58
9
votes
4 answers

Importing matplotlib with reticulate in R

I just started using the reticulate package in R, and I'm still getting a few of the kinks figured out. In particular, importing matplotlib is not going well. I've tried it two different ways, with different error messages for each. First, using…
cjolley
  • 441
  • 6
  • 15
9
votes
1 answer

Importing python module in R

I am trying to import a python module in R using the reticulate package. The module can be found here. I cloned the repository and ran python setup.py install which ran successfully. If I open a python shell, I'm able to import debot. However, when…
Dhiraj
  • 1,650
  • 1
  • 18
  • 44
8
votes
1 answer

How do I make/convert my python app into an Rshiny app? Its a brainteaser! Unable to find what change UI needs in R

i am new to R and trying to understand Rshiny to build UIs. I am trying to create a UI for my python app that transcribes mulitple wav files. There are two parts below, first my python app and the second my shiny app in R which uses reticulate to…
user12384956
1
2 3
32 33