jiffyclub / palettable

Color palettes for Python
https://jiffyclub.github.io/palettable/
Other
768 stars 73 forks source link

restore palettable functionality on OS X if Python is no framework #16

Closed poke1024 closed 7 years ago

poke1024 commented 8 years ago

Currently, on OS X, if palettable won't import due to matplotlib throwing a RuntimeError if Python is not installed as OS X framework:

>>> import palettable
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/demo/jupyter/lib/python3.5/site-packages/palettable/__init__.py", line 7, in <module>
    from . import colorbrewer
  File "/Users/demo/jupyter/lib/python3.5/site-packages/palettable/colorbrewer/__init__.py", line 3, in <module>
    from .colorbrewer import *
  File "/Users/demo/jupyter/lib/python3.5/site-packages/palettable/colorbrewer/colorbrewer.py", line 9, in <module>
    from ..palette import Palette
  File "/Users/demo/jupyter/lib/python3.5/site-packages/palettable/palette.py", line 8, in <module>
    import matplotlib.pyplot as plt
  File "/Users/demo/jupyter/lib/python3.5/site-packages/matplotlib/pyplot.py", line 114, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Users/demo/jupyter/lib/python3.5/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/Users/demo/jupyter/lib/python3.5/site-packages/matplotlib/backends/backend_macosx.py", line 24, in <module>
    from matplotlib.backends import _macosx
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ

This PR adds a check for RuntimeError for the import of matplotlib, so importing matplotlib still fails, but palettable is now usable and doesn't fail as well.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.6%) to 93.22% when pulling 59ec8248de59d5450d18663a5d1b331496f9cd6a on poke1024:master into 29ca166e8eb81797a5417d637f8d0b4901d4dbd0 on jiffyclub:master.

jiffyclub commented 7 years ago

Sorry this PR went unnoticed so long! Does this particular problem still occur with recent versions of matplotlib?

andy-esch commented 7 years ago

I've seen this when trying to build docs. I'm running palettable from a virtual environment, and my python was installed via homebrew.