Incompatibility between rpy2.robjects and plotly

43 Views Asked by At

Problem:

I have been using python rpy2.robjets in combination with R for a long time, where I have called a R script from python with rpy2.robjets.r.source to perform some calculations and then fetched its output.

Recently I have updated R (4.3.0), python (3.11.3), R packages and python packages. In general, the workflow still works, BUT whenever using ggplotly from the plotly R package, when calling from python in PyCharm (2023.2), I get the following message in python: Process finished with exit code -1073740940 (0xC0000374)

I have to point out that running the R script on its own doesn't produce any errors!

What I know about the exit code 1073740940 (0xC0000374) is that it is related to corrupted files. That would have lead me to think it is a incompatibility problem between R and python and their respective packages, but versions of the software and packages are up to date...

Troubleshooting:

Package Info:

sessionInfo():

R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2016 x64 (build 14393)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

time zone: Europe/Berlin
tzcode source: internal

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

other attached packages:
[1] plotly_4.10.1 ggplot2_3.4.2

loaded via a namespace (and not attached):
 [1] vctrs_0.6.2       httr_1.4.6        cli_3.6.1         rlang_1.1.1      
 [5] purrr_1.0.1       generics_0.1.3    jsonlite_1.8.4    data.table_1.14.8
 [9] glue_1.6.2        colorspace_2.1-0  htmltools_0.5.5   scales_1.2.1     
[13] fansi_1.0.4       grid_4.3.0        munsell_0.5.0     tibble_3.2.1     
[17] fastmap_1.1.1     lifecycle_1.0.3   compiler_4.3.0    dplyr_1.1.2      
[21] htmlwidgets_1.6.2 pkgconfig_2.0.3   tidyr_1.3.0       digest_0.6.31    
[25] viridisLite_0.4.2 R6_2.5.1          tidyselect_1.2.0  utf8_1.2.3       
[29] pillar_1.9.0      magrittr_2.0.3    withr_2.5.0       gtable_0.3.3     
[33] lazyeval_0.2.2      

pip list:

Package         Version
--------------- -------
cffi            1.15.1
Jinja2          3.1.2
MarkupSafe      2.1.3
numpy           1.25.2
packaging       23.1
pandas          2.0.3
pip             22.3.1
pycparser       2.21
python-dateutil 2.8.2
pytz            2023.3
rpy2            3.5.13
setuptools      65.5.0
six             1.16.0
tzdata          2023.3
tzlocal         5.0.1

Minimal working example

python file (plotly.py):

import os
os.environ['R_HOME']     = 'C:/Program Files/R/R-4.3.0'
import rpy2.robjects as ro
ro.r.source('plotly.R')

R file (plotly.R):

library(ggplot2)
library(plotly)
ggplotly(ggplot(cars, aes(x = dist,y = speed)) + geom_point())

Any help and ideas would be highly appreciated.

Best Regards, Rok Bohinc

0

There are 0 best solutions below