python matplotlib framework under macosx?


Question

I am getting this error:

/sw/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py:235: UserWarning: Python is not installed as a framework. The MacOSX backend may not work correctly if Python is not installed as a framework. Please see the Python documentation for more information on installing Python as a framework on Mac OS X

I installed python27 using fink and it's using the default matplotlib is using macosx framework.

1
58
12/4/2015 9:17:46 AM

Accepted Answer

There are two ways Python can be built and installed on Mac OS X. One is as a traditional flat Unix-y shared library. The other is known as a framework install, a file layout similar to other frameworks on OS X where all of the component directories (include, lib, bin) for the product are installed as subdirectories under the main framework directory. The Fink project installs Pythons using the Unix shared library method. Most other distributors, including the Apple-supplied Pythons in OS X, the python.org installers, and the MacPorts project, install framework versions of Python. One of the advantages of a framework installation is that it will work properly with various OS X API calls that require a window manager connection (generally GUI-related interfaces) because the Python interpreter is packaged as an app bundle within the framework.

If you do need the functions in matplotlib that require the GUI functions, the simplest approach may be to switch to MacPorts which also packages matplotlib (port py27-matplotlib) and its dependencies. If so, be careful not to mix packages between Fink and MacPorts. It's best to stick with one or the other unless you are really careful. Adjust your shell path accordingly; it would be safest to remove all of the Fink packages and install MacPorts versions.

16
11/9/2010 8:32:04 AM

Some users may not want to change the backend for all of their scripts. This page -- http://matplotlib.org/faq/usage_faq.html#what-is-a-backend -- tells another way:

import matplotlib
matplotlib.use('TkAgg')

You have to do this before importing a subpackage of matplotlib or a third-party package that depends on matplotlib.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon