Title: cannot use GUI backends inside django request handlers · Issue #11094 · matplotlib/matplotlib · GitHub
Open Graph Title: cannot use GUI backends inside django request handlers · Issue #11094 · matplotlib/matplotlib
X Title: cannot use GUI backends inside django request handlers · Issue #11094 · matplotlib/matplotlib
Description: Bug summary Matplotlib crash Python when trying to create a plot and save it as png Bug report Process: Python [7315] Path: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python Identifier: Python V...
Open Graph Description: Bug summary Matplotlib crash Python when trying to create a plot and save it as png Bug report Process: Python [7315] Path: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Co...
X Description: Bug summary Matplotlib crash Python when trying to create a plot and save it as png Bug report Process: Python [7315] Path: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Co...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/11094
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"cannot use GUI backends inside django request handlers","articleBody":"### Bug summary\r\n\r\nMatplotlib crash Python when trying to create a plot and save it as png\r\n\r\n### Bug report\r\n\r\n\u003e Process: Python [7315]\r\n\u003e Path: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python\r\n\u003e Identifier: Python\r\n\u003e Version: 3.6.4 (3.6.4)\r\n\u003e Code Type: X86-64 (Native)\r\n\u003e Parent Process: bash [6754]\r\n\u003e Responsible: Python [7315]\r\n\u003e User ID: 501\r\n\u003e \r\n\u003e Date/Time: 2018-04-20 19:30:12.654 +0300\r\n\u003e OS Version: Mac OS X 10.13.4 (17E199)\r\n\u003e Report Version: 12\r\n\u003e Anonymous UUID: E1B3F20E-1530-E700-1172-1C41E2D223CF\r\n\u003e \r\n\u003e Sleep/Wake UUID: CB1FA7B5-1F06-41C5-8BB7-C34FF5EDF3DC\r\n\u003e \r\n\u003e Time Awake Since Boot: 65000 seconds\r\n\u003e Time Since Wake: 5400 seconds\r\n\u003e \r\n\u003e System Integrity Protection: enabled\r\n\u003e \r\n\u003e Crashed Thread: 0 Dispatch queue: com.apple.main-thread\r\n\u003e \r\n\u003e Exception Type: EXC_CRASH (SIGILL)\r\n\u003e Exception Codes: 0x0000000000000000, 0x0000000000000000\r\n\u003e Exception Note: EXC_CORPSE_NOTIFY\r\n\u003e \r\n\u003e Termination Signal: Illegal instruction: 4\r\n\u003e Termination Reason: Namespace SIGNAL, Code 0x4\r\n\u003e Terminating Process: Python [7315]\r\n\u003e \r\n\u003e Thread 0 Crashed:: Dispatch queue: com.apple.main-thread\r\n\u003e 0 libsystem_kernel.dylib \t0x00000001018f14aa __kill + 10\r\n\u003e 1 org.python.python \t0x00000001008a47bb os_kill + 59\r\n\u003e 2 org.python.python \t0x00000001007be4c8 _PyCFunction_FastCallDict + 552\r\n\u003e 3 org.python.python \t0x0000000100847e94 call_function + 612\r\n\u003e 4 org.python.python \t0x00000001008498a4 _PyEval_EvalFrameDefault + 5604\r\n\u003e 5 org.python.python \t0x0000000100847bde fast_function + 606\r\n\u003e 6 org.python.python \t0x0000000100847e7b call_function + 587\r\n\u003e 7 org.python.python \t0x00000001008498a4 _PyEval_EvalFrameDefault + 5604\r\n\u003e 8 org.python.python \t0x0000000100847230 _PyEval_EvalCodeWithName + 2720\r\n\u003e 9 org.python.python \t0x0000000100847a5b fast_function + 219\r\n\u003e 10 org.python.python \t0x0000000100847e7b call_function + 587\r\n\u003e 11 org.python.python \t0x00000001008498a4 _PyEval_EvalFrameDefault + 5604\r\n\u003e 12 org.python.python \t0x0000000100847230 _PyEval_EvalCodeWithName + 2720\r\n\u003e 13 org.python.python \t0x00000001008480f7 _PyFunction_FastCallDict + 439\r\n\u003e 14 org.python.python \t0x00000001007627c4 _PyObject_FastCallDict + 356\r\n\u003e 15 org.python.python \t0x0000000100762e90 _PyObject_Call_Prepend + 208\r\n\u003e 16 org.python.python \t0x00000001007621b3 PyObject_Call + 99\r\n\u003e 17 org.python.python \t0x000000010084a326 _PyEval_EvalFrameDefault + 8294\r\n\u003e 18 org.python.python \t0x0000000100847230 _PyEval_EvalCodeWithName + 2720\r\n\u003e 19 org.python.python \t0x00000001008480f7 _PyFunction_FastCallDict + 439\r\n\u003e 20 org.python.python \t0x00000001007627c4 _PyObject_FastCallDict + 356\r\n\u003e 21 org.python.python \t0x0000000100762e90 _PyObject_Call_Prepend + 208\r\n\u003e 22 org.python.python \t0x00000001007621b3 PyObject_Call + 99\r\n\u003e 23 org.python.python \t0x000000010084a326 _PyEval_EvalFrameDefault + 8294\r\n\u003e 24 org.python.python \t0x0000000100847230 _PyEval_EvalCodeWithName + 2720\r\n\u003e 25 org.python.python \t0x00000001008480f7 _PyFunction_FastCallDict + 439\r\n\u003e 26 org.python.python \t0x00000001007627c4 _PyObject_FastCallDict + 356\r\n\u003e 27 org.python.python \t0x0000000100762e90 _PyObject_Call_Prepend + 208\r\n\u003e 28 org.python.python \t0x00000001007621b3 PyObject_Call + 99\r\n\u003e 29 org.python.python \t0x000000010084a326 _PyEval_EvalFrameDefault + 8294\r\n\u003e 30 org.python.python \t0x0000000100847230 _PyEval_EvalCodeWithName + 2720\r\n\u003e 31 org.python.python \t0x00000001008480f7 _PyFunction_FastCallDict + 439\r\n\u003e 32 org.python.python \t0x00000001007627c4 _PyObject_FastCallDict + 356\r\n\u003e 33 org.python.python \t0x0000000100762e90 _PyObject_Call_Prepend + 208\r\n\u003e 34 org.python.python \t0x00000001007621b3 PyObject_Call + 99\r\n\u003e 35 org.python.python \t0x000000010084a326 _PyEval_EvalFrameDefault + 8294\r\n\u003e 36 org.python.python \t0x0000000100847bde fast_function + 606\r\n\u003e 37 org.python.python \t0x0000000100847e7b call_function + 587\r\n\u003e 38 org.python.python \t0x00000001008498a4 _PyEval_EvalFrameDefault + 5604\r\n\u003e 39 org.python.python \t0x0000000100847bde fast_function + 606\r\n\u003e 40 org.python.python \t0x0000000100847e7b call_function + 587\r\n\u003e 41 org.python.python \t0x00000001008498a4 _PyEval_EvalFrameDefault + 5604\r\n\u003e 42 org.python.python \t0x0000000100847230 _PyEval_EvalCodeWithName + 2720\r\n\u003e 43 org.python.python \t0x0000000100847a5b fast_function + 219\r\n\u003e 44 org.python.python \t0x0000000100847e7b call_function + 587\r\n\u003e 45 org.python.python \t0x00000001008498a4 _PyEval_EvalFrameDefault + 5604\r\n\u003e 46 org.python.python \t0x0000000100847230 _PyEval_EvalCodeWithName + 2720\r\n\u003e 47 org.python.python \t0x00000001008473d4 PyEval_EvalCode + 100\r\n\u003e 48 org.python.python \t0x0000000100883f7e PyRun_FileExFlags + 206\r\n\u003e 49 org.python.python \t0x000000010088421f PyRun_SimpleFileExFlags + 447\r\n\u003e 50 org.python.python \t0x000000010089d86a Py_Main + 3914\r\n\u003e 51 org.python.python \t0x0000000100000dfe 0x100000000 + 3582\r\n\u003e 52 org.python.python \t0x0000000100000c34 0x100000000 + 3124\r\n\u003e \r\n\u003e Thread 0 crashed with X86 Thread State (64-bit):\r\n\u003e rax: 0x0000000000000000 rbx: 0x000000010da106c8 rcx: 0x00007fff5bffca78 rdx: 0x0000000000000000\r\n\u003e rdi: 0x0000000000001c93 rsi: 0x0000000000000004 rbp: 0x00007fff5bffca90 rsp: 0x00007fff5bffca78\r\n\u003e r8: 0x000000000000006e r9: 0x0000000000000100 r10: 0x00000001015f8070 r11: 0x0000000000000206\r\n\u003e r12: 0x0000000000000000 r13: 0x0000000101bbd948 r14: 0x0000000103519e68 r15: 0x00000001008a4780\r\n\u003e rip: 0x00000001018f14aa rfl: 0x0000000000000206 cr2: 0x00007fff5df24284\r\n\u003e \r\n\u003e Logical CPU: 0\r\n\u003e Error Code: 0x02000025\r\n\u003e Trap Number: 133\r\n\u003e \r\n\u003e Model: MacBookPro11,1, BootROM MBP111.0145.B00, 2 processors, Intel Core i5, 2.6 GHz, 8 GB, SMC 2.16f68\r\n\r\n### Code for reproduction\r\n```python\r\nplt.clf()\r\n\tfor stat in all_subscriber_stats:\r\n\t\troaming_minutes_plot_data.append(stat.roaming_minutes)\r\n\t\troaming_gprs_plot_data.append(stat.roaming_gprs)\r\n\t\tinternational_calls_plot_data.append(stat.international_calls)\r\n\t\treporting_months_grid_data.append(\r\n\t\t\tf\"{stat.reporting_month} / {stat.reporting_year}\"\r\n\t\t)\r\n\ty = [\r\n\t\troaming_minutes_plot_data,\r\n\t\troaming_gprs_plot_data,\r\n\t\tinternational_calls_plot_data\r\n\t]\r\n\tplt.stackplot(\r\n\t\treporting_months_grid_data, y, labels=[\r\n\t\t\t'Roaming minutes',\r\n\t\t\t'Roaming GPRS',\r\n\t\t\t'International calls'\r\n\t\t]\r\n\t)\r\n\tplt.legend(loc='best')\r\n\tplt.ylabel('Rub')\r\n\tplt.xlabel(\"Months\")\r\n\tplt.grid(which='major', axis='both')\r\n\r\n\tplt.savefig(\r\n\t\tf'media/{subscriber.user_phone_number}'\r\n\t)\r\n\tsubscriber.spending_statistics_pic = f'{subscriber.user_phone_number}.png'\r\n\tsubscriber.save()\r\n```\r\n\r\n### Actual outcome\r\n\r\nThe crash of Python and Django server\r\n\r\n### Expected outcome\r\n\r\nmatplotlib should generate the *.png file and place it in the folder\r\n\r\n#### Matplotlib version\r\nmatplotlib installd via pip in PyCharm (venv)\r\n\r\n * **Operating system:** Mac OS X 10.13.4 (17E199)\r\n * **Matplotlib version:** 2.2.2\r\n * **Matplotlib backend** (`print(matplotlib.get_backend())`): module://backend_interagg\r\n * **Python version:** 3.6.4 \r\n * **Other libraries:** \r\ncycler==0.10.0\r\nDjango==2.0.4\r\nkiwisolver==1.0.1\r\nnumpy==1.14.2\r\npandas==0.22.0\r\nPillow==5.1.0\r\npyparsing==2.2.0\r\npython-dateutil==2.7.2\r\npytz==2018.4\r\nsix==1.11.0\r\n\r\n\r\n## Important Note:\r\nSame code with same dependencies versions working 100% on Windows10. The problem is only exclusive to Mac and began when I started using matplotlib in my code\r\n","author":{"url":"https://github.com/SimonOsipov","@type":"Person","name":"SimonOsipov"},"datePublished":"2018-04-20T16:48:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":18},"url":"https://github.com/11094/matplotlib/issues/11094"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8578749a-c5d9-4038-a2fb-dc864ca3a6ba |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BA88:204447:1F29BFA:2B35E27:6A548FDB |
| html-safe-nonce | 9eac3f945722f75f3efbc8cdbc5efd440f8c8c9099f0b8c23ea250fab9ee844f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTg4OjIwNDQ0NzoxRjI5QkZBOjJCMzVFMjc6NkE1NDhGREIiLCJ2aXNpdG9yX2lkIjoiNzg0MjQwNzQzMjk3NDUzNjY2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 08ef58e07565f40cbeff3d5538f34ffbc27152813289627cc80d4385e4c62d9b |
| hovercard-subject-tag | issue:316339179 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/11094/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fe2d00d1955b1b95c9478a998a34b1efaf8b68bb91ebafe5b31fac8a3b35d0ec/matplotlib/matplotlib/issues/11094 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fe2d00d1955b1b95c9478a998a34b1efaf8b68bb91ebafe5b31fac8a3b35d0ec/matplotlib/matplotlib/issues/11094 |
| og:image:alt | Bug summary Matplotlib crash Python when trying to create a plot and save it as png Bug report Process: Python [7315] Path: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | SimonOsipov |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f8cfff6384f62259baea531c7f58bc7040f8dd92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width