Skip to content

macosx broken on python 3.4 non-framework builds, shaky on framework #3367

Closed

Description

@efiring

To reproduce: on Mavericks with Anaconda 2.0.1, python 3.4, Anaconda's default mpl 1.3.1, in ipython:

%matplotlib
import numpy as np
import matplotlib as plt
plt.plot(np.random.randn(10000))

This brings the plot up in a window that cannot even be resized.
I made a modified version of ipython the ipython script:

efiring@manini2:~/anaconda/envs/python3/bin$ diff ipython ipythonf
1c1
< #!/Users/efiring/anaconda/envs/python3/bin/python3

---
> #!/Users/efiring/anaconda/envs/python3/python.app/Contents/MacOS/python

and with this, the plot seems OK, except that it doesn't always register the "enter" event; when the window is selected, moving the cursor from outside to inside sometimes triggers interactivity (the cursor position is shown when inside the axes), but sometimes it doesn't. Moving the cursor inside more slowly seems to help, but it is not very predictable. This flakiness is confirmed with mpl 1.4.0rc3 using homebrew python3.4 with pip-installed ipython; these now link to the framework build.
I was not successful in building mpl from git in the Anaconda environment; shared libraries were not found. Therefore I have not tested the rc3 with the Anaconda default python 3.4.

Activity

  1. added this to the v1.4.0 milestone on Aug 14, 2014
  2. tacaswell commented on Aug 14, 2014

    @tacaswell
    Member

    @mdehoon any thoughts?

    If we are going the drop-osx-backend route, I assume we should only do it for python3?

  3. efiring commented on Aug 14, 2014

    @efiring
    MemberAuthor

    Although it is better on 2.7, I think it still has known problems and major limitations with non-framework builds. Abandoning it would be unfortunate--it is the only interactive backend that is always available on the Mac, without requiring installation of some other enormous and problematic package (e.g., TkTcl, PyQt4, PySide).

  4. efiring commented on Aug 15, 2014

    @efiring
    MemberAuthor

    Progress: it seems that Anaconda is inconsistent, and the intention is for ipython to be run under a framework, but this is not yet happening in 3.4. Chris Barkier and I are still arguing for the framework simply to be the standard python there, so that the ipython script would not have to do anything special, wx apps would work, etc.

  5. efiring commented on Aug 15, 2014

    @efiring
    MemberAuthor

    @mdhoon, the "flakiness" that I noted even with the framework python occurs in 2.7 and 3.4--but only when the cursor is moving between my terminal window and the plot window, not when it enters the plot window from the desktop background. So, there is some sort of interaction between the terminal app and the plot window. It is in the "minor irritation" category, but if you can think of a way of fixing it with a small change in the macosx backend, that would be good.

  6. efiring commented on Aug 15, 2014

    @efiring
    MemberAuthor

    @mdhoon, another question: Is there an easy way to detect at runtime whether mpl is in a python framework build? If there is, then at the very least a warning could be generated if the macosx backend is loaded.

  7. WeatherGod commented on Aug 15, 2014

    @WeatherGod
    Member

    I have a vague recollection of attempts to detect the framework build back
    during the sprints for SciPy 2013. Maybe there is something in the mailing
    list archives on that?

    On Thu, Aug 14, 2014 at 8:15 PM, Eric Firing notifications@github.com
    wrote:

    @mdhoon, another question: Is there an easy way to detect at runtime
    whether mpl is in a python framework build? If there is, then at the very
    least a warning could be generated if the macosx backend is loaded.

    —
    Reply to this email directly or view it on GitHub
    #3367 (comment)
    .

  8. mdehoon commented on Aug 15, 2014

    @mdehoon
    Contributor

    @efiring : Previously we had a runtime check to see if Python is a framework build, but it turned out not to be reliable; see issue #665 . In Python 2 there is a MacOS module that can be used instead:
    $ python
    Python 2.7.6 (default, Jan 20 2014, 14:59:13)
    [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.

    import MacOS
    MacOS.linkmodel
    'framework'

    but this module has disappeared in Python 3:
    $ python3.4
    Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
    [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.

    import MacOS
    Traceback (most recent call last):
    File "", line 1, in
    ImportError: No module named 'MacOS'

    Currently we are checking at compile-time whether we have a framework build (by checking for WITH_NEXT_FRAMEWORK in the C code; this variable is declared in pyconfig.h).
    Since Python 2.7 and 3.2, the information in pyconfig.h is accessible from Python through the sysconfig module. So there we can do:

    import sysconfig
    print(sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'))
    1

    Do we still support Python 3.0 and 3.1? If so, somebody needs to check which of these methods work there. If not, then we can use these methods to check at run-time if we are using a framework build.

    It would be good also if you guys can also check if these methods give the correct answer on your machines.

  9. mdehoon commented on Aug 15, 2014

    @mdehoon
    Contributor

    @efiring : I have not noticed any flakiness with the macosx backend with regular python. If this problem occurs with ipython only, the origin may lie there.

  10. tacaswell commented on Aug 15, 2014

    @tacaswell
    Member

    @ivanov sorry to keep bothering you, Ybut you are a known ipython/mpl connection. Can you bring this to the attention of the proper people in ipython land?

  11. efiring commented on Aug 15, 2014

    @efiring
    MemberAuthor

    @mdehoon,

    1. We do not support Python 3.0 or 3.1, so using sysconfig is OK.
    2. Homebrew python 3.4.1 yields
    In [2]: print(sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'))
    1
    

    but Anaconda 2.7 and 3.4 both yield 0. Presumably this means that even though Anaconda 2.7 has a python.app, it is somehow not a true framework build.
    I note that homebrew sysconfig.get_config_var('CONFIG_ARGS') includes '--enable-framework=/usr/local/Cellar/python3/3.4.1/Frameworks' but Anaconda's does not.
    3) The "flakiness" that I mentioned--the interaction with the terminal, in which moving the cursor from the terminal into the plot window doesn't always activate the interactivity of the plot window--occurs from the plain python prompt, so it is not an ipython-specific problem. It might be related to my terminal configuration, which includes "focus follows mouse" for moves from one terminal window to another.

    [TAC, edit to fix medhoon's user id]

  12. efiring commented on Aug 15, 2014

    @efiring
    MemberAuthor

    I have removed the release_critical label because I think the Anaconda-specific problem will be solved promptly by Anaconda. There are still a bunch of problems floating around:

    1. The interaction with terminal. Minor. One can live with it.
    2. Possible problems in setting default backend: It doesn't look like we can sort all this out quickly, if at all, so I don't think it should block a release.
    3. Ipython problem on Mavericks with qt: severe, and affects us badly, but it looks like entirely an ipython problem at this point; it occurs even when mpl has not been imported.
  13. efiring commented on Aug 15, 2014

    @efiring
    MemberAuthor

    The revised Anaconda ipython for 3.4 is out, and it works.

  14. efiring commented on Aug 15, 2014

    @efiring
    MemberAuthor

    Regarding problem 3 above, see ipython/ipython#6189.

  15. tacaswell commented on Aug 17, 2014

    @tacaswell
    Member

    This seems to have been a combination of up-stream issues. I am tagging at as such an closing as the ipython PRs have been merged and anaconda builds have been updated.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions