Matplotlib - Python的错误 [英] Matplotlib - Python Error

查看:912
本文介绍了Matplotlib - Python的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置:

处理器: x86_64的 操作系统:的GNU / Linux 发行版: Fedora发行13(戈达德)

Processor : x86_64 Operating System: GNU/Linux Distro: Fedora Release 13 (Goddard).

的Python 2.6.4

 /usr/bin/python

下面是下列问题:

我想生成使用Matplotlib和Python的几个图。当我从大多数人的<一听到href="http://stackoverflow.com/questions/7157330/problem-importing-matplotlib-mlab-and-pyplot-in-python-2-7-on-mac-osx-10-6">solutions3..似乎有matplotlib和64位架构之间的兼容性问题。

I am trying to generate a few graphs using Matplotlib and Python. As I hear from a majority of the solutions3.. there seem to be compatibility issues between matplotlib and 64bit architectures.

我从这里

下面是我的错误:

Traceback (most recent call last):
  File "plot-thread-characterization.py", line 24, in <module>
    import matplotlib.pyplot as plt
  File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
  File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in <module>
    import gtk; gdk = gtk.gdk
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
    _init()
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
    _gtk.init_check()
RuntimeError: could not open display

感谢。

推荐答案

matplotlib未能连接到任何X服务器的GTK显示。

matplotlib is failing to connect to any X server for its GTK display.

有几个选择这里:

  1. 运行的本地X服务器和启用X11转发的SSH客户端,以显示你的本地计算机上的输出。您可以通过检查$ DISPLAY环境变量被设置在服务器上验证这是工作。

  1. Run a local X server and enable X11 forwarding in your ssh client, to display the output on your local machine. You can verify this is working by checking that the $DISPLAY environment variable is set on the server.

呼叫matplotlib.use(...)来指定不同的显示后端,比如渲染PDF文件,的的进口pyplot,如:

Call matplotlib.use(...) to specify a different display back-end, for example rendering to pdf file, before importing pyplot, e.g.

进口matplotlib为MPL

mpl.use(AGG的')

进口matplotlib.pyplot为PLT

请参阅<一href="http://matplotlib.org/faq/howto_faq.html#generate-images-without-having-a-window-appear">http://matplotlib.org/faq/howto_faq.html#generate-images-without-having-a-window-appear了解更多详情。

这篇关于Matplotlib - Python的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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