Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: No SFNT name table #1648

Closed
pemistahl opened this issue Jan 9, 2013 · 9 comments
Closed

RuntimeError: No SFNT name table #1648

pemistahl opened this issue Jan 9, 2013 · 9 comments

Comments

@pemistahl
Copy link

I'm on Mac OS X 10.8.2 (Mountain Lion) and using Python 2.7.3 (64-bit version). I have installed the following libraries:

  • NumPy 1.6.2
  • SciPy 0.11.0
  • IPython 0.13.1
  • matplotlib 1.2.0

For installing matplotlib, I used the installer matplotlib-1.2.0-py2.7-python.org-macosx10.6.dmg that is provided on the matplotlib downloads page.

The following import works:

    In [1]: import matplotlib

    In [2]: matplotlib.__version__
    Out[2]: '1.2.0'

However, when I try to import matplotlib.pyplot I get RuntimeError: No SFNT name table. This is the whole stracktrace as given by IPython:

    In [1]: import matplotlib.pyplot as plt
    ---------------------------------------------------------------------------
    RuntimeError                              Traceback (most recent call last)
    <ipython-input-1-eff513f636fd> in <module>()
    ----> 1 import matplotlib.pyplot as plt

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
         24 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
         25 from matplotlib import docstring
    ---> 26 from matplotlib.figure import Figure, figaspect
         27 from matplotlib.backend_bases import FigureCanvasBase
         28 from matplotlib.image import imread as _imread

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py in <module>()
         32 from matplotlib.image import FigureImage
         33 
    ---> 34 import matplotlib.colorbar as cbar
         35 
         36 from matplotlib.axes import Axes, SubplotBase, subplot_class_factory

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
         27 import matplotlib.artist as martist
         28 import matplotlib.cbook as cbook
    ---> 29 import matplotlib.collections as collections
         30 import matplotlib.colors as colors
         31 import matplotlib.contour as contour

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/collections.py in <module>()
         21 import matplotlib.artist as artist
         22 from matplotlib.artist import allow_rasterization
    ---> 23 import matplotlib.backend_bases as backend_bases
         24 import matplotlib.path as mpath
         25 import matplotlib.mlab as mlab

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backend_bases.py in <module>()
         35 import matplotlib.colors as colors
         36 import matplotlib.transforms as transforms
    ---> 37 import matplotlib.widgets as widgets
         38 #import matplotlib.path as path
         39 from matplotlib import rcParams

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/widgets.py in <module>()
         15 from mlab import dist
         16 from patches import Circle, Rectangle
    ---> 17 from lines import Line2D
         18 from transforms import blended_transform_factory
         19 

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/lines.py in <module>()
         23 from artist import allow_rasterization
         24 from matplotlib import docstring
    ---> 25 from matplotlib.font_manager import FontProperties
         26 from matplotlib.markers import MarkerStyle
         27 # Imported here for backward compatibility, even though they don't

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py in <module>()
       1323             verbose.report("Using fontManager instance from %s" % _fmcache)
       1324     except:
    -> 1325         _rebuild()
       1326 
       1327     def findfont(prop, **kw):

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py in _rebuild()
       1310     def _rebuild():
       1311         global fontManager
    -> 1312         fontManager = FontManager()
       1313         pickle_dump(fontManager, _fmcache)
       1314         verbose.report("generated new fontManager")

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py in __init__(self, size, weight)
        987             self.defaultFont['ttf'] = self.ttffiles[0]
        988 
    --> 989         self.ttflist = createFontList(self.ttffiles)
        990 
        991         self.afmfiles = findSystemFonts(paths, fontext='afm') + \

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py in createFontList(fontfiles, fontext)
        577                 #print >> sys.stderr, 'Bad file is', fpath
        578                 continue
    --> 579             prop = ttfFontProperty(font)
        580 
        581         fontlist.append(prop)

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/font_manager.py in ttfFontProperty(font)
        387     #  Styles are: italic, oblique, and normal (default)
        388 
    --> 389     sfnt = font.get_sfnt()
        390     sfnt2 = sfnt.get((1,0,0,2))
        391     sfnt4 = sfnt.get((1,0,0,4))

    RuntimeError: No SFNT name table

I just read in a pretty old thread that it has to do with the file ft2font.so which is linked against a wrong library or something. This is the output of the otool -L command. Does this help?

    $ otool -L /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/ft2font.so

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/ft2font.so:
        /usr/local/lib/libfreetype.6.dylib (compatibility version 16.0.0, current version 16.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

Update: I've installed the newest XQuartz version 2.7.4 but the error still exists. Compiling and installing matplotlib 1.2.0 from source using pip works fine (probably due to to the pre-install of Xcode), when I do import matplotlib.pyplot as plt I get this new error message:

    In [1]: import matplotlib.pyplot as plt
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-1-eff513f636fd> in <module>()
    ----> 1 import matplotlib.pyplot as plt

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
         24 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
         25 from matplotlib import docstring
    ---> 26 from matplotlib.figure import Figure, figaspect
         27 from matplotlib.backend_bases import FigureCanvasBase
         28 from matplotlib.image import imread as _imread

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/figure.py in <module>()
         30 
         31 from matplotlib import _image
    ---> 32 from matplotlib.image import FigureImage
         33 
         34 import matplotlib.colorbar as cbar

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/image.py in <module>()
         20 # For clarity, names from _image are given explicitly in this module:
         21 import matplotlib._image as _image
    ---> 22 import matplotlib._png as _png
         23 
         24 # For user convenience, the names from _image are also imported into

    ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so, 2): Symbol not found: _png_create_info_struct
      Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so
      Expected in: flat namespace
     in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so 

Checking the symlinks again gives:

    $ otool -L /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so:
        /usr/local/opt/libpng/lib/libpng15.15.dylib (compatibility version 28.0.0, current version 28.0.0)
        /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

And here are the statistics given during the build process of matplotlib when installing from source using pip:

    BUILDING MATPLOTLIB
            matplotlib: 1.2.0
                python: 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43)
                        [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
              platform: darwin

    REQUIRED DEPENDENCIES
                 numpy: 1.6.2
             freetype2: 15.0.9

    OPTIONAL BACKEND DEPENDENCIES
                libpng: 1.5.12
               Tkinter: Tkinter: 81008, Tk: 8.5, Tcl: 8.5
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
       Mac OS X native: yes
                    Qt: no
                   Qt4: Qt: 4.8.2, PyQt4: 4.9.4
                PySide: no
                 Cairo: no

    OPTIONAL DATE/TIMEZONE DEPENDENCIES
              dateutil: matplotlib will provide
                  pytz: matplotlib will provide

    OPTIONAL USETEX DEPENDENCIES
                dvipng: 1.14
           ghostscript: 9.05
                 latex: 3.1415926

I don't have this issue with matplotlib version 1.1.1. Shall I switch back to it or can I solve this problem in another way? Thank you very much in advance!

@pemistahl
Copy link
Author

Does nobody have an idea how this issue can be fixed? It's open now for about two months and I haven't found a solution myself so far.

@efiring
Copy link
Member

efiring commented Mar 3, 2013

I'm baffled. Your setup looks reasonably similar to mine, and presumably to that of many other people. There must be some subtle difference, but I don't see anything that could account for it. Your latest error message indicates a problem linking with libpng. My otool output is slightly different:

efiring@manini2:~/work/programs/py/mpl$ otool -L /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so:
    /usr/local/lib/libpng15.15.dylib (compatibility version 29.0.0, current version 29.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

So my libpng is in a different location and is a very slightly different version; it is hard to imagine how those differences could matter, but I suppose you might try reinstalling libpng and recompiling.

Instead of using pip, you might want to use git to clone the repo from github and build explicitly from source. That way you can more easily switch versions, and it is easier to see what is going on.

@pelson
Copy link
Member

pelson commented Mar 4, 2013

Since SFNT is related to fonts, have you cleared out any potential gotchas by removing your ~/.matplotlib folder?

@mdboom
Copy link
Member

mdboom commented Mar 7, 2013

There is some font on your system that it doesn't like. It would be helpful if we could figure out what that font file is, and then maybe you could send it to me in a private email and I'll try to reproduce the bug locally.

The easiest way to do this is to:

  1. Add verbose: debug-annoying to your ~/.matplotlib/matplotlibrc file

  2. Remove ~/.matplotlib/fontList.cache

  3. Start up python and type import matplotlib

The last font file name displayed should be the culprit. Hopefully from that file I can determine what's going on.

@pemistahl
Copy link
Author

@mdboom Sorry for my late answer. I just tried what you suggested. However, the font files are only displayed if I do import matplotlib.pyplot instead of import matplotlib. The problematic font file on my machine seems to be

/Users/Peter/Library/Fonts/NimbusSanL-Regu.ttf 

This is the only font file in the Fonts directory of my account's Library, by the way. I don't even remember which program installed this font. It could have been installed by my MacTeX distribution, but I'm not sure. When I delete this font, matplotlib imports just fine. Once the file fontList.cache has been re-created, I can put the font file back into its original directory and all subsequent imports of matplotlib work just fine.

I can send you the font file if you provide me an email address. Anyway, thanks for your help.

@dmcdougall
Copy link
Member

@pemistahl Do any of these look familiar? Like you say, it'd be nice to know where that came from.

@mdboom
Copy link
Member

mdboom commented Apr 18, 2013

@pemistahl : Sorry for the delay. I can't reproduce this locally with a version of NimbusSansL-Regu.ttf I found online, so perhaps there's something specific to your version. Could you please send it to mdboom at gmail dot you-know-what?

@pelson
Copy link
Member

pelson commented May 28, 2013

Removing the blocker label. If this was a wider issue I'd have expected more people to comment, but it seems that this is probably an installation/machine specific issue.

@mdboom
Copy link
Member

mdboom commented Aug 26, 2013

Closing due to lack of response.

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

No branches or pull requests

5 participants