[PYTHON] How to suppress display error in matplotlib

When the code published on github etc. is based on the assumption that there is a display, a display error occurs and it does not work! Write a memo about what to do in such a case.

Both methods have matplotlib in the background and can reduce errors.

Let's suppress in the code

Write as follows in the python code.

import matplotlib
matplotlib.use("Agg")

Let's suppress on a user-by-user basis

File name: matplotlibrc Create a text file (without extension) and write the following character string in the file. backend:Agg

Save this file locally (create it if it doesn't exist) For Linux home/usename/.matplotlib

At the end

Since it was an environment where only CUI could be used, I investigated a workaround several years ago. The latter method may cause an accident if you forget the setting, so the former method is recommended. Don't rely on plt.show (). I want you to stop.

Recommended Posts

How to suppress display error in matplotlib
How to display multiplication table in python
How to display Hello world in python
How to use Matplotlib
How to display images continuously with matplotlib Note
How to display videos inline in Google Colab
[Python] How to draw a histogram in Matplotlib
How to apply markers only to specific data in matplotlib
How to display multiple images of galaxies in tiles
How to eliminate garbled characters in matplotlib output image
How to display DataFrame as a table in Markdown
How to add color bars in matplotlib bar plot
How to develop in Python
How to pass matplotlib backend settings in environment variables
How to install poetry (error handling) in zsh environment
[AWS] How to deal with "Invalid codepoint" error in CloudSearch
[Python] How to do PCA in Python
How to handle session in SQLAlchemy
[Rails] How to display Google Map
How to use classes in Theano
How to write soberly in pandas
How to collect images in Python
How to update Spyder in Anaconda
How to use SQLite in Python
How to run matplotlib on heroku
How to convert 0.5 to 1056964608 in one shot
How to reflect CSS in Django
How to kill processes in bulk
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use PubChem in Python
How to run TensorFlow 1.0 code in 2.0
How to handle Japanese in Python
How to log in to Docker + NGINX
How to call PyTorch in Julia
How to intentionally issue an error in the shell During testing
How to deal with python installation error in pyenv (BUILD FAILED)
How to display formulas in latex when using sympy (> = 1.4) in Google Colaboratory
Two ways to display multiple graphs in one image with matplotlib
How to display legend marks in one with Python 2D plot
How to display bytes in the same way in Java and Python
How to use calculated columns in CASTable
How to display the progress bar (tqdm)
Display LaTeX notation formulas in Python, matplotlib
How to title multiple figures with matplotlib
How to access environment variables in Python
[Memo] How to use BeautifulSoup4 (1) Display html
[Python] How to display random numbers (random module)
How to dynamically define variables in Python
How to do R chartr () in Python
How to draw a graph using Matplotlib
Display matplotlib diagrams in a web application
How to convert csv to tsv in CLI
How to delete expired sessions in Django
[Itertools.permutations] How to put permutations in Python
How to use Google Test in C
How to implement nested serializer in drf-flex-fields
How to work with BigQuery in Python
Display Matplotlib xy graph in PySimple GUI.
How to execute commands in jupyter notebook