pylab without X11

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Willem-Jan Vriend

    #1

    pylab without X11

    I want to use pylab (matplotlib) on a machine without X11. I'm trying to
    generate onthefly graphics for an apache2 web service, so they do not
    have to be displayed on this machine !

    When i do
    pylab.figure()
    I get the error
    TclError: couldn't connect to display ":0.0"

    I tried setting the DISPLAY environment variable to "", ":0.0" but I got
    the same error message.

    Any help is very much appreciated.
  • marc

    #2
    Re: pylab without X11

    This may help you ... or not

    You may have to change your backend :

    p13 of the matplotlib user guide: backends
    p17 how to change the backend in the matplotlibrc

    An example of matplotlibrc ( backend choice is at the beginning ):


    You may choose PS or SVG or pdf, there might be other possibilities, I
    do not know
    To save the file : savefig



    Marc




    Willem-Jan Vriend a écrit :
    I want to use pylab (matplotlib) on a machine without X11. I'm trying to
    generate onthefly graphics for an apache2 web service, so they do not
    have to be displayed on this machine !
    >
    When i do
    pylab.figure()
    I get the error
    TclError: couldn't connect to display ":0.0"
    >
    I tried setting the DISPLAY environment variable to "", ":0.0" but I got
    the same error message.
    >
    Any help is very much appreciated.

    Comment

    • marc

      #3
      Re: pylab without X11

      This may help ... or not ( 2nd part )

      try not to do pylab.figure()

      in your script:
      pylab.plot, or pylab.imshow or whatever you want to use
      then
      savefig("myFigu re.png") for example
      do not use show()


      in my case ( with the WXAgg backend ), it works, it generates the png file

      Marc





      Willem-Jan Vriend a écrit :
      I want to use pylab (matplotlib) on a machine without X11. I'm trying to
      generate onthefly graphics for an apache2 web service, so they do not
      have to be displayed on this machine !
      >
      When i do
      pylab.figure()
      I get the error
      TclError: couldn't connect to display ":0.0"
      >
      I tried setting the DISPLAY environment variable to "", ":0.0" but I got
      the same error message.
      >
      Any help is very much appreciated.

      Comment

      • Willem-Jan Vriend

        #4
        Re: Re: pylab without X11

        Thanks that worked ! I changed the backend to Agg.

        Allthough a problem there is that with the backend Agg you only can
        write the resulting image to a file or a file like object, it does not
        accept the (apache) request handler to write the file to. And I do not
        want to save the file to disk first before sending to the client.

        WJV

        marc wrote:
        <div class="moz-text-flowed" style="font-family: -moz-fixed">This may
        help you ... or not
        >
        You may have to change your backend :
        >
        p13 of the matplotlib user guide: backends
        p17 how to change the backend in the matplotlibrc
        >
        An example of matplotlibrc ( backend choice is at the beginning ):

        >
        You may choose PS or SVG or pdf, there might be other possibilities, I
        do not know
        To save the file : savefig
        >
        >
        >
        Marc
        >
        >
        >
        >
        Willem-Jan Vriend a écrit :
        >I want to use pylab (matplotlib) on a machine without X11. I'm trying
        >to generate onthefly graphics for an apache2 web service, so they do
        >not have to be displayed on this machine !
        >>
        >When i do
        > pylab.figure()
        >I get the error
        > TclError: couldn't connect to display ":0.0"
        >>
        >I tried setting the DISPLAY environment variable to "", ":0.0" but I
        >got the same error message.
        >>
        >Any help is very much appreciated.
        >
        </div>
        >

        Comment

        Working...