I have a container running with Python/JupyterLab and all of my dependencies. I start it with:
docker run --rm -it -p 8888:8888 \
--mount type=bind,source=/project,target=/work \
python-3.9.1-jupyterlab
It launches jupyterlab and I can connect through the browser. Everything is good.
Now I am experimenting with using VSCode as a Python IDE. It is helpful to attach a shell from VSCode to my container so I can run iPython and edit my code all in one place. I run "attach shell" from the VSCode Docker extension:
docker exec -it {containerID} bash <
Then I open an iPython shell:
jo@:~/work $ ipython --pylab
Python 3.9.1
IPython 7.20.0 -- An enhanced Interactive Python.
Using matplotlib backend: agg
In [1]: matplotlib.get_backend()
Out[1]: 'agg'
In [2]: import matplotlib.pyplot as plt
In [3]: plt.plot([1.6, 2.7])
Out[3]: [<matplotlib.lines.Line2D at 0x7f5ed0ed8d30>]
In [4]: plt.show()
In [5]: %matplotlib inline
In [6]: plt.plot([1.6, 2.7])
Out[6]: [<matplotlib.lines.Line2D at 0x7f5ed0df5d60>]
<Figure size 432x288 with 1 Axes>
In [7]: plt.show()
I cannot see any plots. I have tried rendering them with different backends (default was 'agg'). I am thinking this is because the kernel -- executing on the container -- cannot make use of the host graphics (i.e., kernel can render plots but cannot display them). Perhaps I do not have host/container ports mapped properly.
Could someone provide some guidance on things to try? Here is the image for the container I am using.