在 Ubuntu 上导入 matplotlib [英] Importing matplotlib on Ubuntu

查看:40
本文介绍了在 Ubuntu 上导入 matplotlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我下载并安装了matplotlib.奇怪的是,当将示例放置在home/user/Desktop中时,我可以很好地运行这些示例,但是当我将它们移到home/user/Documents中时,它们停止工作,并且得到以下消息.关于Documents文件夹,有什么特别的东西可以阻止matplotlib导入?

So I downloaded and installed matplotlib. The weird things is that I can run the examples fine when they were placed in home/user/Desktop but when I moved them to home/user/Documents, they stopped working and I get the below message. Is there something special about the Documents folder that they prevent matplotlib from importing?

Traceback (most recent call last):
  File "contour_manual.py", line 4, in <module>
    import matplotlib.pyplot as plt
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 23, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 18, in <module>
    from axes import Axes, SubplotBase, subplot_class_factory
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/axes.py", line 8454, in <module>
    Subplot = subplot_class_factory()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/axes.py", line 8446, in subplot_class_factory
    new_class = new.classobj("%sSubplot" % (axes_class.__name__),
AttributeError: 'module' object has no attribute 'classobj'

推荐答案

您是否有机会在 Documents 文件夹中找到文件 new.py ?如果有,请尝试将其重命名为其他名称.

Do you have a file new.py in your Documents folder, by any chance? If you have, try renaming it to something else.

matplotlib 模块 axes.py 导入 new,如果您的 Documents 文件夹中有一个文件 new.py将导致Python加载它,而不是内置的 new 模块.

The matplotlib module axes.py imports new, and if you have a file new.py lying around in your Documents folder, that will cause Python to load it instead of the built-in new module.

这篇关于在 Ubuntu 上导入 matplotlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆