Skip to content

matplolib empty figure on OS X when using conda-forge's tk #36

Closed

Description

@ocefpaf

From @efiring:

So it seems that the problem is not at all dependent on mpl version,
and not really dependent on installation method, either. Instead, it might
depend on the exact tk build:

My original "py37" environment (yielding a plot) had tk 8.6.9-ha92aebf_0
from conda-forge. Now I updated that to match the fresh environment 
("mpl2") version, 8.6.9-h2573ce8_1002, and I get the white screen. 
Switching back to the earlier tk build, I get the plot again.

When I downgrade tk in "mpl2" to 8.5.19, it downgrades a bunch of 
other things including python to 3.6; but the test yields a window, 
and the buttons work!

@ocefpaf it looks like there might be something very fiddly with tk
versions and builds for OSX in conda-forge.

Original issue: matplotlib/matplotlib#12074

@efiring I don't have a macOS to test this and I cannot reproduce it on Linux. @conda-forge/tk team: anyone here with a macOS to take a look at this?

Activity

  1. efiring commented on Jun 26, 2019

    @efiring

    Possibly related: #30.

  2. guyer commented on Jul 5, 2019

    @guyer

    As far as I can tell, the problem was introduced with build 1001 of 8.6.9:

    $ conda create -n tk_8.6.9_1000_mpl_2.2.4 --channel conda-forge tk=8.6.9=ha441bb4_1000 matplotlib=2.2.4
    $ conda activate tk_8.6.9_1000_mpl_2.2.4
    $ MPLBACKEND=TkAgg python -c "from matplotlib import pyplot as plt; plt.plot([1., 2., 3.], [5., 4., 3.]); plt.show()"
    

    renders as expected, but

    $ conda create -n tk_8.6.9_1001_mpl_2.2.4 --channel conda-forge tk=8.6.9=ha441bb4_1001 matplotlib=2.2.4
    $ conda activate tk_8.6.9_1001_mpl_2.2.4
    $ MPLBACKEND=TkAgg python -c "from matplotlib import pyplot as plt; plt.plot([1., 2., 3.], [5., 4., 3.]); plt.show()"
    

    produces a blank window.

    Same thing with Matplotlib 3.1.1.

    tk 8.6.8 and tk 8.6.9 build 0 and build 1000 are fine.
    tk 8.6.9 build 1001 and build 1002 are not.

    macOS 10.14.5 (18F132)

  3. efiring commented on Jul 5, 2019

    @efiring

    Reminder: there are actually two problems related to tk versions. matplotlib/matplotlib#12074 (comment)

    1. The white window problem, which @guyer narrowed down as starting with 8.6.9 build 1001.
    2. Unreliable response to toolbar buttons, which I find in builds 0 and 1000 of 8.6.9, but not in 8.5.19.
  4. smithsp commented on Jul 13, 2019

    @smithsp
    Contributor

    I have reports of this on Mac for another tk application.

  5. vishalmhjn commented on Jul 13, 2019

    @vishalmhjn

    I am not using conda but pip and virtualenv. I am also facing the same problem as the matplotlib fails to render the plots and python crashes. System details: macOS 10.14.5, Python 3.6, Virtualenv pip

  6. Miakatt commented on Jul 19, 2019

    @Miakatt

    I don't know if this helps, but I found that running my code with python3 explicitly allows the plotting to work correctly. With python only, the plotting windows are blank.

    $ which python
     /Users/me/anaconda3/envs/pmp/bin/python
    $ which python3
     /Users/me/anaconda3/envs/pmp/bin/python3
    
    

    Both python and python3:

    Python 3.7.3 | packaged by conda-forge | (default, Jul  1 2019, 14:38:56) 
    [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
    
    

    Matplotlib version 2.2.3
    tk version 8.6.9

  7. vishalmhjn commented on Jul 19, 2019

    @vishalmhjn

    @Miakatt What is your macOS version?

  8. Miakatt commented on Jul 19, 2019

    @Miakatt

    @vishalmhjn It's Mojave. I'm not at the computer right now to supply the full version number I'm afraid. I can update on Monday.

  9. Miakatt commented on Jul 26, 2019

    @Miakatt

    Sorry, I need to make a correction to the above. My plotting works if I use MacOSX backend, but not the default TkAgg backend.
    Using:
    matplotlib.use('MacOSX')
    or setting this in the ~/.matplotlib/matplotlibrc file fixes the plots for me.

  10. Meteodan commented on Aug 15, 2019

    @Meteodan

    I came across this thread searching for why gitk stopped working for me, and I'm convinced now that it is for the same reason as this problem with matplotlib. Specifically, I'm using "gitk" that comes installed with the git mac os x binary (version 2.2.0). When it invokes wish, it uses the version installed with my anaconda3 environment (Tk version 8.6.9) since it is ahead of it in my $PATH, and I get nothing but a blank window. After deactivating my anaconda environment, gitk uses /usr/bin/wish, which uses Tk/Tcl version 8.5 (presumably the Apple versions), and the window opens correctly.

    Before Mojave, this was never an issue, as I recall.

  11. mingwandroid commented on Aug 15, 2019

    @mingwandroid

    Thanks @Meteodan.

    While this may be something we should investigate, you should also file a bug with git about gitk if you wouldn't mind?

    The bug would be along the lines that software that knows where its other bits live should not use PATH to locate or launch those other bits. It should instead use relative paths from known-to-exist filepaths.

  12. Meteodan commented on Aug 15, 2019

    @Meteodan

    @mingwandroid

    Yes, of course, I will do so. Thank you for your reply.

  13. vishalmhjn commented on Aug 26, 2019

    @vishalmhjn

    Sorry, I need to make a correction to the above. My plotting works if I use MacOSX backend, but not the default TkAgg backend.
    Using:
    matplotlib.use('MacOSX')
    or setting this in the ~/.matplotlib/matplotlibrc file fixes the plots for me.

    Thanks for the reply..But this doesn't work on mine. Same problem

  14. ocefpaf commented on Jan 2, 2023

    @ocefpaf
    MemberAuthor

    Looks like this issue is fixed in the latest version. Let's close this and open a new one if we see it again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions