Anaconda:matplotlib PdfPages导入错误

时间:2017-06-02 09:06:57

标签: python matplotlib anaconda attributeerror pdfpages

我在anaconda环境中从matplotlib包导入PdfPages函数时遇到问题。我收到以下错误:

Python 2.7.13 |Anaconda 4.4.0 (64-bit)| (default, Dec 20 2016, 23:09:15) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from matplotlib.backends.backend_pdf import PdfPages
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 32, in <module>
    from matplotlib.backend_bases import (RendererBase, GraphicsContextBase,
  File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 63, in <module>
    import matplotlib.textpath as textpath
  File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/textpath.py", line 17, in <module>
    import matplotlib.font_manager as font_manager
  File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1439, in <module>
    _rebuild()
  File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/font_manager.py", line 1421, in _rebuild
    with cbook.Locked(cachedir):
  File "/home/hpc/capn/mppi033h/.virtualenv/h5_to_histo_env/lib/python2.7/site-packages/matplotlib/cbook.py", line 2738, in __enter__
    files = glob.glob(self.pattern)
AttributeError: 'module' object has no attribute 'glob'

导入matplotlib(导入matplotlib)工作正常。我在用Anaconda创建的虚拟环境中运行python(/.../。virtualenv / h5_to_histo_env /)

根据conda-V,我的版本是'conda 4.3.16',而我的matplotlib版本是2.0.2('np112py27_0')。 我的Anaconda环境也是最新的,有人知道我为什么会出现这个错误吗?

1 个答案:

答案 0 :(得分:0)

更新:重新安装虚拟anaconda环境并在开头使用conda create命令指定所需的软件包(而不是在创建虚拟环境后),以某种方式修复它!