0

我刚刚matplotlib (1.2.1)在新的 Python 安装 (2.7.4) 上安装了最新的稳定版本和最新的稳定版本IPython (0.13.2)

我跑matplotlib.test()了,最终结果如下:

matplotlib.test() 总结

----------------------------------------------------------------------
Ran 1251 tests in 857.869s

FAILED (KNOWNFAIL=312, SKIP=3, failures=2)
/home/avazquez/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/__init__.py:1033: UserWarning:  This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.

  warnings.warn(_use_error_msg)
Out[2]: False

我应该如何解释这个消息?安装是否matplotlib未通过测试?

如果有帮助,下面是更详细的输出:

运行 matplotlib.test()

In [1]: import matplotlib

In [2]: matplotlib.test()
....K...K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K...K..K..K..K..K..K..K..K..K..K..K..K...K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K...K.SSS.K..............K..K..K..K..K..K..KK.................................................................K....K....K...K..K..K.K..KK....K..K..K..K......................................................................................................................................................................................K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K........K.......K...K..K..K..K..K..K...K..K..K.....K..K.....

/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/font_manager.py:1224: UserWarning: findfont: Font family ['sans-serif'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/font_manager.py:1234: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=normal:stretch=normal:size=14.0. Returning /opt/Python-2.7.3-x86_64/lib/python2.7/site-packages/matplotlib-1.2.0-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  UserWarning)
/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/font_manager.py:1234: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=bold:stretch=500:size=14.0. Returning /opt/Python-2.7.3-x86_64/lib/python2.7/site-packages/matplotlib-1.2.0-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  UserWarning)
/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/font_manager.py:1224: UserWarning: findfont: Font family ['sans serif'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))
/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/font_manager.py:1234: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=italic:variant=normal:weight=750:stretch=500:size=14.0. Returning /opt/Python-2.7.3-x86_64/lib/python2.7/site-packages/matplotlib-1.2.0-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  UserWarning)
/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/font_manager.py:1234: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=200:stretch=500:size=14.0. Returning /opt/Python-2.7.3-x86_64/lib/python2.7/site-packages/matplotlib-1.2.0-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  UserWarning)
/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/font_manager.py:1234: UserWarning: findfont: Could not match :family=Bitstream Vera Sans:style=normal:variant=normal:weight=500:stretch=100:size=14.0. Returning /opt/Python-2.7.3-x86_64/lib/python2.7/site-packages/matplotlib-1.2.0-py2.7-linux-x86_64.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  UserWarning)
FFK..K.......K..K..K..K..K/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/gridspec.py:298: UserWarning: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.
  warnings.warn("This figure includes Axes that are not "
..K..K.........................K....KK
======================================================================
FAIL: matplotlib.tests.test_text.test_font_styles.test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 39, in failer
    result = f(*args, **kwargs)
  File "/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 158, in do_test
    '(RMS %(rms).3f)'%err)
ImageComparisonFailure: images not close: /nfs/drive5/opt/python/virtualenvs/work/result_images/test_text/font_styles.png vs. /nfs/drive5/opt/python/virtualenvs/work/result_images/test_text/font_styles-expected.png (RMS 47.353)

======================================================================
FAIL: matplotlib.tests.test_text.test_font_styles.test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 39, in failer
    result = f(*args, **kwargs)
  File "/home/james/opt/python/virtualenvs/work/lib/python2.7/site-packages/matplotlib/testing/decorators.py", line 158, in do_test
    '(RMS %(rms).3f)'%err)
ImageComparisonFailure: images not close: /nfs/drive5/opt/python/virtualenvs/work/result_images/test_text/font_styles_pdf.png vs. /nfs/drive5/opt/python/virtualenvs/work/result_images/test_text/font_styles-expected_pdf.png (RMS 23.423)

这是安装日志的一部分:

从 virtualenv 安装 matplotlib:

$ pip install matplotlib
Downloading/unpacking matplotlib
  Downloading matplotlib-1.2.1.tar.gz (38.4MB): 38.4MB downloaded
  Running setup.py egg_info for package matplotlib
    basedirlist is: ['/usr/local', '/usr']
    ============================================================================
    BUILDING MATPLOTLIB
                matplotlib: 1.2.1
                    python: 2.7.4 (default, Apr 21 2013, 18:37:10)  [GCC 4.1.2
                            20080704 (Red Hat 4.1.2-50)]
                  platform: linux2

    REQUIRED DEPENDENCIES
                     numpy: 1.7.1
                 freetype2: 9.10.3

    OPTIONAL BACKEND DEPENDENCIES
                    libpng: 1.2.10
                   Tkinter: no
                            * Using default library and include directories for
                            * Tcl and Tk because a Tk window failed to open.
                            * You may need to define DISPLAY for Tk to work so
                            * that setup can determine where your libraries are
                            * located. Tkinter present, but header files are not
                            * found. You may need to install development
                            * packages.
                      Gtk+: no
                            * Building for Gtk+ requires pygtk; you must be able
                            * to "import gtk" in your build/install environment
           Mac OS X native: no
                        Qt: no
                       Qt4: no
                    PySide: no
                     Cairo: no

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

    OPTIONAL USETEX DEPENDENCIES
                    dvipng: 1.5
               ghostscript: 8.70
                     latex: 3.141592
                   pdftops: 3.00

    [Edit setup.cfg to suppress the above messages]
    ============================================================================
    pymods ['pylab']
    packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']

    warning: no files found matching 'KNOWN_BUGS'
    warning: no files found matching 'INTERACTIVE'
    warning: no files found matching 'make.osx'
    warning: no files found matching 'MANIFEST'
    warning: no files found matching '__init__.py'
    warning: no files found matching 'examples/data/*'
    warning: no files found matching 'lib/mpl_toolkits'
    warning: no files found matching 'lib/matplotlib/mpl-data/matplotlib.conf'
    warning: no files found matching 'lib/matplotlib/mpl-data/matplotlib.conf.template'
    warning: manifest_maker: MANIFEST.in, line 16: 'recursive-include' expects <dir> <pattern1> <pattern2> ...

    warning: no files found matching 'LICENSE*' under directory 'license'
Installing collected packages: matplotlib
  Running setup.py install for matplotlib
    basedirlist is: ['/usr/local', '/usr']
    ============================================================================
    BUILDING MATPLOTLIB
                matplotlib: 1.2.1
                    python: 2.7.4 (default, Apr 21 2013, 18:37:10)  [GCC 4.1.2
                            20080704 (Red Hat 4.1.2-50)]
                  platform: linux2

    REQUIRED DEPENDENCIES
                     numpy: 1.7.1
                 freetype2: 9.10.3

    OPTIONAL BACKEND DEPENDENCIES
                    libpng: 1.2.10
                   Tkinter: no
                            * Using default library and include directories for
                            * Tcl and Tk because a Tk window failed to open.
                            * You may need to define DISPLAY for Tk to work so
                            * that setup can determine where your libraries are
                            * located. Tkinter present, but header files are not
                            * found. You may need to install development
                            * packages.
                      Gtk+: no
                            * Building for Gtk+ requires pygtk; you must be able
                            * to "import gtk" in your build/install environment
           Mac OS X native: no
                        Qt: no
                       Qt4: no
                    PySide: no
                     Cairo: no

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

    OPTIONAL USETEX DEPENDENCIES
                    dvipng: 1.5
               ghostscript: 8.70
                     latex: 3.141592
                   pdftops: 3.00

    [Edit setup.cfg to suppress the above messages]
    ============================================================================
    pymods ['pylab']
    packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz', 'dateutil', 'dateutil.zoneinfo']

TKinter?

我也很惊讶 matplotlib 报告的安装Tkinter: No。我可以导入TkinterIPython

In [1]: import Tkinter
In [2]: _tkinter.TK_VERSION
Out [2]: '8.5'
In [3]: Tkinter.__version__
Out[3]: '$Revision: 81008 $'
4

1 回答 1

1

忽略这两个失败是安全的。

那些测试,嗯,很挑剔。他们在我的一些机器上的 master 上失败了,似乎传给了 Travis。如果您想确切了解失败的原因,请查看 /nfs/drive5/opt/python/virtualenvs/work/result_images/test_text/并比较font_styles.pngfont_styles-expected_pdf.png. 我强烈怀疑这将是字体移动了几个像素。

于 2013-04-25T23:18:15.023 回答