{"id":1058,"hash":"7f396d288fd0d88488628d3332e0d8cdd0a5752f2b2dc722bbfe888076f426a8","pattern":"&quot;UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.&quot; when plotting figure with pyplot on Pycharm","full_message":"I am trying to plot a simple graph using pyplot, e.g.:\n\nimport matplotlib.pyplot as plt\nplt.plot([1,2,3],[5,7,4])\nplt.show()\n\nbut the figure does not appear and I get the following message:\n\nUserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.\n\nI found and tried some advice to re-configure the \"backend\" mentioned in that warning, like so:\n\nimport matplotlib\nmatplotlib.use('TkAgg')\nimport matplotlib.pyplot as plt\n\nbut this gives me an error message:\n\nModuleNotFoundError: No module named 'tkinter'\n\nI assumed that I had to install this module separately, but pip install tkinter does not work:\n\nCollecting tkinter\n  Could not find a version that satisfies the requirement tkinter (from versions: )\nNo matching distribution found for tkinter\n\nHow can I make Matplotlib display the graph?\n\nSee also: Why does tkinter (or turtle) seem to be missing or broken? Shouldn't it be part of the standard library? . This question is not a duplicate, because the answers discuss other backends besides the Tkinter one.\n\nAlso see _tkinter.TclError: no display name and no $DISPLAY environment variable for issues with attempts to use Matplotlib remotely.","ecosystem":"pypi","package_name":"matplotlib","package_version":null,"solution":"Solution 1: is to install the GUI backend tk\nI found a solution to my problem (thanks to the help of ImportanceOfBeingErnest).\n\nAll I had to do was to install tkinter through the Linux bash terminal using the following command:\n\nsudo apt-get install python3-tk\n\ninstead of installing it with pip or directly in the virtual environment in Pycharm.\n\nSolution 2: install any of the matplotlib supported GUI backends\n\nsolution 1 works fine because you get a GUI backend... in this case the TkAgg\nhowever you can also fix the issue by installing any of the matplolib GUI backends like Qt5Agg, GTKAgg, Qt4Agg, etc\n\nfor example pip install pyqt5 will fix the issue also\n\nNOTE:\n\nusually this error appears when you pip install matplotlib and you are trying to display a plot in a GUI window and you do not have a python module for GUI display.\nThe authors of matplotlib made the pypi software deps not depend on any GUI backend because some people need matplotlib without any GUI backend.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/56656777/userwarning-matplotlib-is-currently-using-agg-which-is-a-non-gui-backend-so","votes":505,"created_at":"2026-04-19T04:52:15.476169+00:00","updated_at":"2026-04-19T04:52:15.476169+00:00"}