Reticulate is awesome, and I love that we can run python code but get all the goodies of RMarkdown including publishing to Connect.
While reticulate (using RStudio Preview 1.2) works fine on my local machine, when I try to run it with an RStudio Server Preview 1.2 running on an AWS EC2 instance, I get an error
"TclError: couldn't connect to display ":0"
Detailed traceback:
File "<string>", line 1, in <module>
File "/home/rstudio/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2748, in plot
return gca().plot(
File "/home/rstudio/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 934, in gca
return gcf().gca(**kwargs)
File "/home/rstudio/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 577, in gcf
return figure()
File "/home/rstudio/.local/lib/python3.6/site-packages/matplotlib/pyplot.py", line 524, in figure
**kwargs)
File "/home/rstudio/.local/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 3218, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
File "/home/rstudio/.local/lib/python3.6/site-packages/matplotlib/backends/_backend_tk.py", line 1008, in new_figure_manager_given_figure
window = Tk.Tk(className="matplotlib")
File "/usr/lib/python3.6/tkinter/__init__.p"
FYI -- I'm running RStudio Server on Ubuntu 18.04. I've installed tkinter using sudo apt-get install python3-tk or I get an error about "ImportError: No module named 'tkinter'" when I try to show the plot.
The display environmental variable on RStudio Server is
Sys.getenv("DISPLAY")
[1] ":0"
while on my Mac it's
Sys.getenv("DISPLAY")
[1] "/private/tmp/com.apple.launchd.dajCiOg7ER/org.macosforge.xquartz:0"
so I suspect there's an issue that matplotlib doesn't know where to display the plot. Any suggestions on how to solve this issue?