Matplotlib plots cause RStudio crash

When trying to create matplotlib plots using reticulate::repl_python() Rstudio crashes.

Some code that causes this problem for me:

First start python REPL

reticulate::repl_python()
import pandas as pd
df = pd.DataFrame({
  'x': [1,2,3],
  'y': [4,5,6]
})
df.plot.scatter(x='x', y= 'y')

This is true for the the preview release 1.2.679-1, was true on installing the most recent nightly build of rstudio and was also true on the most recent release. I have no such problems using python from the command line or other IDEs. I was just wondering if other had experienced this and knew of a fix?

Some info that may help diagnose:

> reticulate::py_config()
python:         /filestore/ubuntu/anaconda3/bin/python
libpython:      /filestore/ubuntu/anaconda3/lib/libpython3.6m.so
pythonhome:     /filestore/ubuntu/anaconda3:/filestore/ubuntu/anaconda3
version:        3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)  [GCC 7.2.0]
numpy:          /filestore/ubuntu/anaconda3/lib/python3.6/site-packages/numpy
numpy_version:  1.14.3

python versions found: 
 /filestore/ubuntu/anaconda3/bin/python
 /usr/bin/python
 /usr/bin/python3
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C               LC_TIME=en_GB.UTF-8       
 [4] LC_COLLATE=en_GB.UTF-8     LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       

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

loaded via a namespace (and not attached):
[1] compiler_3.4.4   Matrix_1.2-12    tools_3.4.4      Rcpp_0.12.17     reticulate_1.7.2
[6] grid_3.4.4       jsonlite_1.5     png_0.1-7        lattice_0.20-35 

OS is Ubuntu 18.04

2 Likes

I ran into the same issue when I was building a docker container with ubunutu 18.04 recently. I'm pretty sure that installing python3-tk with apt-get was the thing that fixed it.

1 Like

Thanks for replying, I have ensured that python3-tk is isntalled. Unfortunately this does not solve my problem.