Hi, I tried the below code:
knitr::opts_chunk$set(echo = TRUE)
library(reticulate)
use_condaenv(condaenv = "py3", conda = "/home/itamar/dev/apps/miniconda3/bin/conda")
numpy <- import("numpy")
plot <- import("matplotlib.pyplot")
x <- numpy$arange(0.1, 2.0, 0.1)
y <- x^2
plot$plot(x,y) # <---- R Session Aborted Here
When python$python(x,y)
runs rstudio shows:
R Session Aborted
R encountered fatal an error
The session was terminated
When I run the same as python code its fine.
it's a clean ubuntu installation with clean anaconda installation (installed all today):
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"
Our experience has been that attempting to use matplotlib with Anaconda Python doesn't work well due to incompatible versions of Qt between RStudio and Python being loaded:
opened 02:52PM - 22 Jun 18 UTC
closed 11:42AM - 07 Aug 18 UTC
Trying to run the following Python chunk results in RStudio crashing as soon as … a plot related functions is run:
```python
import numpy as np
import matplotlib.pyplot as plt
n = 256
X = np.linspace(-np.pi,np.pi,n,endpoint=True)
Y = np.sin(2*X)
plt.plot (X, Y+1, color='blue', alpha=1.00)
plt.plot (X, Y-1, color='blue', alpha=1.00)
plt.show()
```
![python](https://user-images.githubusercontent.com/7488029/41783087-4d6354fe-763c-11e8-81d0-b13cdc5d949a.png)
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
[5] LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] reticulate_1.8.0.9000 forcats_0.3.0 stringr_1.3.1 dplyr_0.7.5 purrr_0.2.5 readr_1.1.1
[7] tidyr_0.8.1 tibble_1.4.2 ggplot2_2.2.1 tidyverse_1.2.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 compiler_3.4.0 cellranger_1.1.0 pillar_1.2.3 plyr_1.8.4 bindr_0.1.1 tools_3.4.0
[8] lubridate_1.7.4 jsonlite_1.5 nlme_3.1-137 gtable_0.2.0 lattice_0.20-35 pkgconfig_2.0.1 rlang_0.2.1
[15] Matrix_1.2-14 psych_1.8.4 cli_1.0.0 rstudioapi_0.7 parallel_3.4.0 haven_1.1.1 bindrcpp_0.2.2
[22] xml2_1.2.0 httr_1.3.1 hms_0.4.2 grid_3.4.0 tidyselect_0.2.4 glue_1.2.0 R6_2.2.2
[29] readxl_1.1.0 foreign_0.8-70 modelr_0.1.2 reshape2_1.4.3 magrittr_1.5 scales_0.5.0.9000 rvest_0.3.2
[36] assertthat_0.2.0 mnormt_1.5-5 colorspace_1.3-2 stringi_1.1.7 lazyeval_0.2.1.9000 munsell_0.5.0 broom_0.4.4
[43] crayon_1.3.4
We still don't fully understand the issue (nor why matplotlib is attempting to use Qt) but we're tracking the underlying issue there.
1 Like
Thank you. RStudio is awesome. I have recently posted first few questions like this one on the forum and I have to say that I was struck by the responsiveness and professionalism.
3 Likes