FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Plotting with Tkinter on Mojave 10.14.6 causes a crash & log out · Issue #14999 · matplotlib/matplotlib · GitHub

Repository navigation

Plotting with Tkinter on Mojave 10.14.6 causes a crash & log out #14999

Closed

Description

Bug report

Bug summary

Trying to view a plot made with Python 3.7, Spyder, and IPython with the Tkinter backend causes a crash and the macOS Mojave login screen appears.

Code for reproduction

Any kind of plot will cause the problem.

import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10)
y = 2 * x
plt.plot(x, y)

Actual outcome

Crash and the Mojave 10.14.6 login screen appears.

The problem started occurring after the update to Mojave 10.14.6. When I create a plot and click on the plot window icon on the dock, the screen goes black for a second and the macOS login screen appears. After I log in, the windows of Anaconda Navigator and Spyder are gone and their icons are no longer present on the Dock. Activity Monitor however indicates that python is still running.

I have reproduced this behavior a few times. Switching the IPython backend to Qt5 solved the problem.

Expected outcome

A plot.

Matplotlib version

  • Operating system: MacOS Mojave 10.14.6 (Darwin 18.7.0)
  • Matplotlib version: 3.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): Tkinter
  • Python version: 3.7.3
  • Jupyter version (if applicable): n/a
  • Other libraries: Spyder 3.3.6, IPython 7.6.1
    Running the stock Anaconda Distribution 2019.07.

Activity

  1. jklymak commented on Aug 7, 2019

    Member

    can You reproduce without spyder? Are you sure tkinter is up to date. For what it’s worth I’ve never really had tk working on my Mac

  2. evangelos1 commented on Aug 7, 2019

    Author

    Hi Jody,

    Yes. It seems this may not be a matplotlib-specific issue after all. See ContinuumIO/anaconda-issues#11165

    Actually I only switched to Tkinter from Qt5 recently to avoid a slow execution problem with IPython 7.6. Then this crash issue started occurring after the recent macOS 10.14.6 update. Eventually I switched back to Qt5 and downgraded to IPython 6.5. Everything seems to be working as expected at the moment.

  3. broulston commented on Aug 7, 2019

    I have also started experiencing this crash and logout since I updated to Mojave 10.14.6. I haven't had any issues with any backends before this. I also kind of get an error message:

    2019-08-07 09:43:59.219 python[5309:540054] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted

    2019-08-07 09:43:59.221 python[5309:536396] HIToolbox: received notification of WindowServer event port death.

    2019-08-07 09:43:59.221 python[5309:536396] port matched the WindowServer port created in BindCGSToRunLoop

    I just checked quick and it crashes when using Python 3.7.3, in both python and the ipython interpreter. Switching the backend to Qt5Agg seems to be working.

    • Operating system: MacOS Mojave 10.14.6 (Darwin 18.7.0)
    • Matplotlib version: 3.0.3, 3.1.0
    • Matplotlib backend (print(matplotlib.get_backend())): TkAgg
    • Python version: 3.7.3
    • Jupyter version (if applicable): n/a
  4. Dmaturana81 commented on Aug 15, 2019

    Same happened to me.
    Yesterday I ran my script that use Tkinter and Matplotlib everything perfect. Today morning I updated th MacOSX, try to run the script and I got kicked off to the login window.
    Then I try to run the tests from tinter library, and the same happened.

    MacOSX Mojave 10.14.6
    matplotlib 3.0.3
    Python 3.6
    Pycharm 2018.1.4
    tkinter

  5. tacaswell commented on Aug 16, 2019

    Member

    At least one person has reported this to Apple (ContinuumIO/anaconda-issues#11165 (comment)) not sure if this is a case where more reports helps let them know this is a real problem or not...

    This appears to be an interaction between tk and OSX which we can not do much about on the Matplotlib side of things.

  6. linscafe commented on Aug 17, 2019

    Adding these two lines solved the problem for me.
    import matplotlib
    matplotlib.use("TkAgg")

  7. MountainKing91 commented on Aug 19, 2019

    I had the same issue today; for the first time in 2 weeks i tried to run a python script featuring the tkinter library in a jupiter notebook (anaconda navigator): the screen went black for a few seconds and then the macOS login screen appeared. After I logged in, the windows of Anaconda Navigator and Jupiter are gone and their icons are no longer present on the Dock. I tried to open the Anaconda Navigator again and i got the following message: "there is an instance of anaconda navigator already running".
    I tried multiple times this whole process but I always had the same result.
    I couldn't find any explanation surfing the net and googling.

  8. manishkothakonda commented on Aug 19, 2019

    @yiilih Adding the two lines:
    import matplotlib
    matplotlib.use("TkAgg")

    was still crashing, I still did not figure out the problem. Let me know if anyone has figured out the mac crashing problem due to Tkinter.

  9. efiring commented on Aug 19, 2019

    Member

    This is a Tk problem; we can't do anything about it. Closing.

  10. added this to the milestone on Sep 10, 2019
  11. ImpatientLearning commented on Sep 17, 2019

    I know that this is a closed issue but since I didn't find a solution here I will share with you what worked for me. Downgrading from python 3.7.3 to python 3.7.0 solved my issue.

    ContinuumIO/anaconda-issues#11165 (comment)

  12. michael-iuzzolino commented on Sep 19, 2019

    Here's a complete solution that worked for me using Conda.

    Setup the environment using Python 3.7.0, as @ImpatientLearning suggested.
    $ conda create --n <env_name> python=3.7.0 pip
    $ conda activate <env_name>

    Install Matplotlib version 3.0.3
    (env_name) $ pip install matplotlib==3.0.3

    Finally, as @yiilih suggested, at the top of your <script_name>.py

    import matplotlib
    matplotlib.use('TkAgg')
  13. JasonZhu1313 commented on Oct 15, 2019

    Here's a complete solution that worked for me using Conda.

    Setup the environment using Python 3.7.0, as @ImpatientLearning suggested.
    $ conda create --n <env_name> python=3.7.0 pip
    $ conda activate <env_name>

    Install Matplotlib version 3.0.3
    (env_name) $ pip install matplotlib==3.0.3

    Finally, as @yiilih suggested, at the top of your <script_name>.py

    import matplotlib
    matplotlib.use('TkAgg')

    It works for me. Just downgrade your python from 3.7.* to 3.7.0 and add those two lines.

  14. adamlyu93 commented on Feb 13, 2020

    I have the same issue and updating to macOS 10.15 solved my problem. I am using python 3.7.0, tk 8.6.8 in anaconda.

  15. harryparker commented on Feb 18, 2020

    I have the same problem. Just ran "conda update --all" trying to resolve it. It didn't. However, after reading the related bug report at ContinuumIO/anaconda-issues#11165,
    I tried replacing "python -m tkinter" (which kicked me out to the login screen) with
    "pythonw -m tkinter". That worked!
    I also noted that pythonw runs python 3.7.0 rather than python 3.7.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL