OS X: 10.9 Mavericks, Python, & Canopy

(Revised January 21, 2015 to refer to Mac crash article  - subscribe to this article for updates -- to the right of the article's title)

Summary: If you are using Mavericks, update to Canopy 1.4.1 (or higher). If you previously disabled AppNap for Python, you can re-enable it.

OS X 10.9 Mavericks was released on October 22, 2013.  There are several compatibility issues which may require fixes in Mavericks, Python, Canopy, and (IPython and/or Matplotlib and/or Qt and/or wx). The most critical issues are fixed in Canopy 1.3 and higher.

In Canopy 1.1, several partial workarounds are available, but only consider these if for some organizational reason you are not allowed to update.

Crash on waking from sleep

Please see "Canopy Crashes on Mac OS X". 

IPython Pylab/Matplotlib issues:  workarounds for Canopy 1.1

Canopy 1.2+ users can skip this section. 

IPython shell

Canopy's Python shell panel is an embedded IPython QtConsole. By default, it runs in Pylab mode, with interactive Qt as the backend. In this configuration, Pylab becomes intolerably slow for even the simplest commands, apparently because of the new "App Naps" feature in Mavericks.


1) The simplest workaround, if you do not need interactive graphics, is to change to a non-interactive backend. Go the Canopy / Preferences menu, select "Python", and under "Pylab backend", select "Inline (SVG)".

If you do need interactive graphics, you have several options:

2) Disable App Nap for Python. Open a Terminal, and type the following command (thanks to IPython's MinRK):

defaults write org.python.python NSAppSleepDisabled -bool YES

After this, the Ipython shell should run in Canopy at normal speed. 


3) Run ipython (or qtconsole) from the command line, with osx as the pylab backend (replace 64bit with 32bit if appropriate):

~/Library/Enthought/Canopy_64bit/User/bin/ipython  qtconsole  --pylab=osx

 This OSX backend will work for Matplotlib but not for Mayavi, Enable, or Chaco.

 

Fix: Canopy 1.2+'s default IPython, and its GUI application's embedded QtConsole, include MinRK's fixes at https://github.com/ipython/ipython/pull/4453, which appears to fix the backend issues for Qt and Wx.

 

IPython notebook

Canopy 1.1's Python notebook runs in Pylab mode, with interactive Qt as the backend. In this configuration, Pylab becomes intolerably slow under OS X Mavericks, apparently due to both backend and frontend interactions.

The only known workarounds are to run the ipython notebook from the command line. 


1) Easiest is to use OSX as the pylab backend (replace 64bit with 32bit if appropriate):

~/Library/Enthought/Canopy_64bit/User/bin/ipython  notebook  --pylab=osx

This OSX backend will work for Matplotlib but not for Mayavi, Enable, or Chaco.


2) To continue to use QT as the pylab backend, disable App Nap in your default browser, (Right-click in dock / Options / Show in Finder / Right-click / Info / General / Prevent App Nap.). Then:

QT_API=pyside  ~/Library/Enthought/Canopy_64bit/User/bin/ipython  notebook  --pylab=qt

 

Fix: Canopy 1.2+ GUI application's embedded notebook supports Qt, Wx, and inline backends on all platforms. Canopy 1.2+'s default IPython, and the GUI application's embedded notebook, includes MinRK's fixes at https://github.com/ipython/ipython/pull/4453, which appears to fix both frontend and backend issues for all supported backends. 

Python issues

For Python-Mavericks issues, and at least one reference to more general Mavericks issues, see this thread on the Python-Dev discussion list. These issues will not necessarily affect most Canopy users, but it's too early to be sure. The just-released Python 2.7.6 addresses these issues, and is included in Canopy 1.3 and higher.

Resources / Links

Ipython report, for discussion of IPython-Mavericks issues, and App Nap in particular.

This Macworld article includes a paragraph about App Nap, including how to disable it for a particular application.

http://www.imore.com/os-x-mavericks-review

http://reviews.cnet.com/8301-13727_7-57588576-263/memory-compression-brings-ram-doubler-to-os-x-mavericks/

http://stackoverflow.com/questions/19722580/segfault-11-with-pandas...

http://stackoverflow.com/questions/19531969/segmentation-fault-11-i...

Feedback 

If the above workarounds fail for you, or you devise other workarounds, please leave a comment below. Thanks!

Have more questions? Submit a request

Comments

  • Avatar
    Kenn Herskind

    Immediately after I installed Maverick, Canopy/Python slowed down to a pace that made it unusable for anything practical.

    I then had a period of normal work speed (hooray), but now, after a reboot, down to snail pace (*sigh*).

    Trying to figure out what is going on...

  • Avatar
    Richard Klaver

    Early adopter here too. Upgraded to Mavericks and had a complete slow down as well. I did a full uninstall of 64-Canopy and all associated files, reinstalled with the same slow experience. A simple arithmetic operation took a several seconds.

  • Avatar
    Baris Onan

    printing Hello World to the terminal and getting ready for next input takes about 15 seconds :) Wish i didn't rush the OS update. :(

    Running Canopy 1.1.1.1452 64 bit version.

  • Avatar
    Mohsen Jadidi
  • Avatar
    Saqib Qazi

    [Ed: consolidating Saqib's 2 reports. Thanks, Saqib!]

    32 bit Canopy+Python slow down after upgrading to Mavericks. Uninstalled Canopy and tried installing the 64 bit version and then later the 32 bit version again - did not help. Both versions worked normally for the first few minutes however, before slowing down...


    Thank you Jonathan, problems solve. Disabled App Nap for Canopy.app and all instances of Python.app and PythonNoDock.app in my applications folder. Not sure if I needed to do this for all of these apps, but since things seem to be running fine for now, don't want to rock the boat...

  • Avatar
    Mike Alport

    [Ed: consolidating Mike's 3 reports. Thanks, Mike!]:

    Somewhat of a mixed report:

    I found and checked the option "Prevent App Nap" in the Canopy App info - and also selected Canopy's Pylab backend "Inline" but it made no difference! Even tried a machine reboot.

    Currently, everything in the Notebook window is very sluggish - scrolling, text selection and cell execution - and hence unusable.

    But the responses in the iPython window below the Notebook, seems to be fine.

    Canopy V1.1.1 (64-bit)


    Just to add to my previous comment, opening a .py file instead of a .ipynb file does NOT produce any of the sluggishness of the latter.

    i.e. editing a .py file seems fine - no problem with scrolling and text selection. Thus the problem seems to be specific to the Notebook cell environment.


    Saqib's solution has not worked for me [ed: in Notebook]:

    I disabled App Nap for Canopy (in Applications) and also for the Python and PythonNoDock apps in Canopy_64bit/System and Canopy_64bit/User.

    Scrolling seems to be a little better, but text selection is still unusable.

  • Avatar
    Conor Fleming

    After upgrading directly from Snow Leopard 10.6.8 to Mavericks I also experienced this issue. Canopy would take 4 seconds to add 2+2 in the iPython terminal. 

    I have just disabled 'App Nap' for Canopy, Mayavi (64-bit).app and Pylab (64-bit).app, and now Canopy seems to run fine again - both in the terminal and running scripts. 

    Incidentally, I start Canopy using the 'canopy' command in Terminal.app - this is because I add some module directories to PYTHONPATH using my .bashrc file. 

  • Avatar
    Jonathan March

    Article reorganized to highlight most promising workaround, and be clearer. No significant change in content.

  • Avatar
    Mike Alport

    I have disabled App Nap as suggested in("immediate workaround) above as well as the Pylab and Mayavi Apps in /Enthought Canopy (64-bit)/  but slow scroll in Notebook and slow text selection problems remain. Starting Canopy from terminal command also doesn't seem to work as suggested by Conor - although interestingly 2x Canopy sessions are started???

    Until this is sorted, I am going to run Notebook in Safari using: 

    ipython notebook --pylab=qt

    from a terminal session. This doesn't seem to have any problems.

     

  • Avatar
    Min RK

    I would recommend against using the Qt matplotlib backend for now on 10.9, as that seem to be the culprit.  The Cocoa ('macosx') or inline backends do not seem to be affected, and two-process IPython without matplotlib also appears unaffected.

    If you do need to use a Qt backend, or you encounter the issue without Qt, you may want to set the global preference to avoid Python apps sleeping with AppNap:

    defaults write org.python.python NSAppSleepDisabled -bool YES

     From looking at Info.plist, this should affect Canopy as well as any other Python.

  • Avatar
    Peter Rusello

    The AppNap workaround above seems to have solved the slowdown issue for me. Checking after disabling AppNap on each of the suggested applications above (Canopy, then the Python*.app applications), it seems disabling it on the User/Resources/Python.app actually solved the issue. I went ahead and disabled it on all of them though. This was running with the wx backend.

  • Avatar
    Michael Dalby

    I've had success like Peter's, by checking to disable AppNap on all five suggested applications, then restarting Canopy. 

  • Avatar
    Fabio Lamanna

    Hi all,

    I've just bought a new macbook air with Mavericks already installed. I've been using Canopy only to manage packages, but I'm working with Python script outside it, on a text editor. By the way, I'm referring to the installed Enthought Canopy Python 2.7.3 Environment. Should I have to worry installing Canopy, but working outside of it? I mean, the compatibility problems affects only the Canopy application or the whole Python working environment?

    Thanks for your support!

  • Avatar
    David Protter

    First I tried the above AppNap solution, but it didnt work.

    Then I switched the Canopy preferences for the PyLab backend to SVG and that seems to have solved the problem, although I don't really understand what that means/what the true implications of this switch are. Good luck everyone!

  • Avatar
    Jonathan March

    @Fabio - the Python issues referenced above will also occur outside of Canopy but do not seem severe. The IPython issues referenced above will also occur running in pylab mode with a Qt backend. Not entirely clear when else it will occur, but so far, "ipython --pylab=osx" seems to work ok.

  • Avatar
    Jonathan March

    @David, Sorry and surprised that the NoApp solution didn't work for you. FYI, SVG ("inline") backend produces static non-interactive graphics. 

  • Avatar
    Mike Alport

    More info:

    I have checked all 5 files fro No App Nap in File info, selected "wx" backend and rebooted Canopy.

    The problems remain. Please can everyone adding comments be specific about just what "problems" they are referring to?

    In my case the problems are:

    1) Slow/jerky scrolling of the Notebook window and

    2) Slow (5 seconds!) to show a highlighted 10 characters of text in the Notebook window wham that text is cursor selected.

    Both these problems are not experienced when running Notebook in a browser from the terminal prompt: 

    ipython notebook --pylab=qt

    Either people are not referring to the same problems or there is some other difference in our configuration/environment that has not yet been identified.

  • Avatar
    Myles Gartland

    Prevented AppNap as above. It completely fixed the problem when working with the editor. The Ipython notebook is still slow (both tying and executing) however.

  • Avatar
    Jonathan March

    Article re-written almost completely to reflect current understanding and simplest workarounds.

  • Avatar
    Sturla Molden

    Any news on when we can expect Python 2.7.6?

  • Avatar
    Sturla Molden

    Also note the compiler change from llvm-gcc-4.2.1 to clang-500.2.79. /usr/bin/gcc is now a symlink to clang, and /usr/bin/g++ is a symlink to clang++. One nasty effect of this is transition from GNU libstdc++ to clang libc++ for C++ binaries. I am not sure if Canopy is affected, but it is causing havoc for users of Homebrew, as all C++ dependencies seem to be broken. Also, the Intel C++ compiler is now binary compatible with a compiler that does not exist on Mavericks (llvm-gcc-4.2.1). If C++ libraries starts to behave strangely on Mavericks (e.g Qt and wxWidgets), the C++ standard library is among the possible culprits.

     

  • Avatar
    Sturla Molden

    Also note that to build many C extensions on Mavericks, we first have to run the undocumented system call

    $ /usr/bin/xcode-select --install

    This brings back many command line tools and header files that were wiped out by the upgrade to Mavericks and Xcode 5. This includes the C header files for POSIX.

  • Avatar
    Jonathan March

    Thanks for the heads-ups, Sturla.

    Canopy 1.3, scheduled for January, will include Python 2.7.6.

    Canopy 1.2, scheduled for November, will include Min's fixes at https://github.com/ipython/ipython/pull/4453, unless dragons emerge from lairs. 

  • Avatar
    Jonathan March

    Note that the OSX backend will work for Matplotlib but not for Mayavi, Enable, or Chaco. For these, the manual AppNap fix is necessary in Canopy 1.1.

     

  • Avatar
    Jonathan March

    Update: Canopy 1.2 is now scheduled for the beginning of December. It will include Min's fixes at https://github.com/ipython/ipython/pull/4453, which appears to fix the issues with Qt and Wx pylab backends. Canopy 1.2 will not add support for the OSX backend within the Canopy GUI application because of Canopy/Mayavi/Chaco compatibility issues. (Pylab users from terminal can still use the OSX backend as always.)

  • Avatar
    Brad Parry

    Just bought a Mac today, installed Canopy and then...wtf? And found this thread -- thanks for your collective work on the issue(s). I'm guessing the poor quality rendering in matplotlib is a known issue as well? Is this expected to be resolved?

    Since I use Python/Canopy extensively for research, I might return this thing if the bug fixes will seem to be an issue.....

  • Avatar
    Jonathan March

    @Brad, actually this is the first I've heard of matplotlib rendering issues. Please send a report with screenshot to canopy.feedback@enthought.com. Which backend? Other details? Also, FYI, Ubuntu runs nicely in a Fusion VM on Mac (at least in earlier versions of OSX!)

  • Avatar
    Sturla Molden

    I have not seen any problems with Matplotlib, but I will check again :)

    Homebrew had a stability issue with Matplotlib which was related to Agg and Boost and the C++ stdlib issue I mentioned above.

    Bugfixes on Mavericks will not be a problem I think. There are just some initial problems. Python 2.7.6 and a few patches to ipython will take care of it. Just give it a cople of months. Enthought needs some time to test all their packages against Python 2.7.6. Right now it just looks more badly than it really is. Also note that turning off AppNap for Python and Canopy is not "worse" than running Python/Canopy in Mountain Lion.

    We should not complain about Apple implementing AppNap or retiring the old gcc-4.2.1 frontend in favor of clang-5.0. AppNap saves battery on laptops, by putting idle applications to sleep. But ipython's design with multiple processes does not play nicely with it. clang-5.0 has support for C99 and C++11 right out of the box. Intel is working on porting OpenMP to clang/llvm. That is good news for scientific developers.

    Anyone serious about scientific computing should have a dedicated computer or a VM (e.g. Oracle Virtualbox) with a solid Linux distro. If you depend a lot on Python/Canopy, you know where to find Red Hat or Ubuntu. Oracle Virtualbox is free (GPL), VMware Fusion is not. Both are very solid VMs.

  • Avatar
    Jonathan March

    Min's patch also seems to fix the frontend slowdown in Canopy's integrated IPython notebook.

  • Avatar
    Brad Parry

    Thank-you for the tips Jonathan and Sturla. I'm an ex-Matlab-devotee making the transition....

    I will fire an email over with a screenshot. I'm using Mavericks out of the box and last night installed the latest version Canopy.

    Maybe I am being picky about the rendering. I have not tried saving my plots in any type of vector graphics format. Maybe if I save them as pdf and then view them, they will be fine...OK, I just did this. On both Mavericks and Windows 7, if I save a plot as *.pdf, the output file is really nice. However, if do something in python like:

    plot(arange(0,10),sin(arange(0,10))

    the plot that is displayed looks pixelated at all zoom levels on Mavericks compared to Windows 7. Even the text and buttons on the figure window are pixelated. But it is strange because all other text in the editor and ipython is nice and sharp.

    The Canopy version I am using on Mavericks is 1.1.1.1452

Please sign in to leave a comment.