导入matplotlib的偶然错误

时间:2015-07-21 02:45:55

标签: python matplotlib import

在新创建的终端中,我可以import matplotlib没有错误。但是,在终端中工作一段时间后,会发生以下情况:

Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Usage: example.py torrentfile.torrent
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py", line 134, in <module>
    from matplotlib.rcsetup import (defaultParams,
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/rcsetup.py", line 19, in <module>
    from matplotlib.colors import is_color_like
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/colors.py", line 54, in <module>
    import matplotlib.cbook as cbook
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/cbook.py", line 15, in <module>
    import new
  File "new.py", line 12, in <module>
    with open(sys.argv[1], 'rb') as fh:
IndexError: list index out of range

出了什么问题?

1 个答案:

答案 0 :(得分:0)

在@CaptainMurphy和@ IronManMark20的帮助下,我在new.py下发现new.pyc~/temp,它会隐藏一些matplotlib个文件。删除它们后,问题就解决了。