简体   繁体   中英

Anaconda: matplotlib PdfPages import error

I've a problem with importing the PdfPages function from the matplotlib package on my anaconda environment. 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. I'm running python in a virtual environment created with Anaconda (/.../.virtualenv/h5_to_histo_env/)

According to conda-V my version is 'conda 4.3.16' and my matplotlib version is 2.0.2 ('np112py27_0'). My Anaconda environment is up to date as well, does anybody know why I get this error?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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