简体   繁体   English

Anaconda:matplotlib PdfPages导入错误

[英]Anaconda: matplotlib PdfPages import error

I've a problem with importing the PdfPages function from the matplotlib package on my anaconda environment. 我在anaconda环境中从matplotlib包导入PdfPages函数时遇到问题。 I get the following error: 我收到以下错误:

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'

Importing matplotlib (import matplotlib) works fine though. 导入matplotlib(导入matplotlib)虽然可以。 I'm running python in a virtual environment created with Anaconda (/.../.virtualenv/h5_to_histo_env/) 我正在使用Anaconda(/.../.virtualenv/h5_to_histo_env/)创建的虚拟环境中运行python

According to conda-V my version is 'conda 4.3.16' and my matplotlib version is 2.0.2 ('np112py27_0'). 根据conda-V的说法,我的版本是'conda 4.3.16',而我的matplotlib版本是2.0.2('np112py27_0')。 My Anaconda environment is up to date as well, does anybody know why I get this error? 我的Anaconda环境也是最新的,有人知道我为什么会收到此错误吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM