[PYTHON] What to do if the image is not displayed using matplotlib etc. in the Docker container

When I tried to display an image with matplotlib etc. in the Docker container, I wrote it. I am doing it in Ubuntu 16.04.6 LTS environment.

[problem] After Docker run, enter the container and plot.show () with matplotlib, no image is displayed and the command ends. Or

docker _tkinter.TclError: couldn't connect to display _tkinter.TclError: no display name and no $DISPLAY environment variable _tkinter.TclError: couldn't connect to display :0.0 I get an error like this.

[approach] ① First, transfer the following command to the terminal

$sudo apt-get install x11-xserver-utils
$xhost +

② When doing docker run, add the following to the options -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY

③ If matplotlib is not in the container, in interactive mode after starting the container

pip install matplotlib

④ If tkinter is not in the container, in interactive mode after starting the container

apt-get update
apt-get install python3-tk

When installing python3-tk, there was a question about the area of residence.

Now the image is displayed well even in the container. : family:

Recommended Posts

What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do if the progress bar is not displayed in tqdm of python
What to do when Japanese is not displayed on matplotlib
What to do if Python IntelliSense is not displayed in VS Code on Windows
What is wheezy in the Docker Python image?
What to do if you get "Python not configured." Using PyDev in Eclipse
What to do if abort is displayed when inputting camera video in OpenCV
What to do if pyenv is not enabled (zsh)
What to do if (base) is displayed at the beginning of the Mac terminal
What to do when is not in the sudoers file.This incident will be reported.
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if Python does not switch from the System version in pyenv
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
What to do if the inode is exhausted on EC2 Linux
What to do if you can't use the trash in Lubuntu 18.04.
What to do when the value type is ambiguous in Python?
The date is displayed incorrectly in matplotlib.
What to do if the user name is changed and the pyenv library path does not pass
What to do if there is a decimal in python json .dumps
What to do when the result downloaded via scrapy is in English
What to do if the Pipenv environment is corrupted by updating Homebrew
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
What to do when a warning message is displayed in pip list
[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
What to do if pipreqs results in UnicodeDecodeError
Even if the development language is changed to python3 in Cloud9, version 2 is displayed in python --version
[Python] What to do if an error occurs in pip (pyinstaller, pyautogui, etc.)
What is the reason why the basic commands are not displayed in Japanese in man?
Why Docker is so popular. What is Docker in the first place? How to use
What to do when the graph does not appear in jupyter (ipython) notebook
What to do if NotADirectoryError: [Errno 20] Not a directory:'xdg-settings' appears in jupyter notebook
What to do if a version error occurs in the selenium Chrome driver
What to do if Japanese language support is not completely installed on Ubuntu 16.04
What to do if you get the error RuntimeError: Python is not installed as a framework when trying to use matplitlib and pylab in Python 3.3
What to do if a UnicodeDecodeError occurs in pip
Do not pass self to ProcessPoolExecutor in the class
What to do if sys / cdefs.h does not exist
What to do if the print command itself causes an error in Maya python
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do if you can't hit the arrow keys in the Python interactive console
What to do if Jupyter Notebook on WSL does not start automatically in your browser
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium
What to do if the package dependency cannot be repaired
What to do if pip gives a DistributionError in Homebrew
What to do when a Missing artifact occurs in a jar that is not defined in pom.xml
What to do if you get "coverage unknown" in Coveralls
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
The image is displayed in the local development environment, but the image is not displayed on the remote server of VPS
Check when the Docker container does not connect to the Internet
What to do if `pip install matplotlib` fails on Mac
What to do if you can't log in as root
What to do if you get angry with "Gtk * backend requires pygtke to be installed" even though pygtk is included in matplotlib
What to do if an error message "There was a problem displaying this web page" is displayed in Chrome's Web Driver (Selenium)
[Beginner] What to do when "[Errno 2] File b'test.csv' does not exist: b'test.csv" is displayed when reading pandas csv
[Short note] In matplotlib, nothing is displayed even if I show it → Check the backend setting
What to do if you cat or tail a binary file and the terminal is garbled
What to do if you get angry with'vertices' must be a 2D list ... in matplotlib arrow
What to do when a part of the background image becomes transparent when the transparent image is combined with Pillow
NameError: global name'dot_parser' is not defined and what to do when it comes up in python
What to do if you get a minus zero in Python