Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8064737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:27:32+00:00 2026-06-05T11:27:32+00:00

I want to plot (i.e. write a file) with matplotlib from a script that

  • 0

I want to plot (i.e. write a file) with matplotlib from a script that runs as a subprocess (launched by a python cgi-script from an apache server), but somehow either the plot isn’t created or the server crashes depending on the backend I use. I think I should be using “agg”, and the plot is created in that case, but the server crashes then (internal server error). Here’s the log:

AH01215: /usr/lib/pymodules/python2.7/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display, referer: http://localhost/
AH01215:   warnings.warn(str(e), _gtk.Warning), referer: http://localhost/
AH01215: /usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_gtk.py:49: GtkWarning: IA__gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed, referer: http://localhost/
AH01215:   cursors.MOVE          : gdk.Cursor(gdk.FLEUR),, referer: http://localhost/
malformed header from script 'submit.cgi': Bad header: ['/home/user/..., referer: http://localhost/

The cgi-script doens’t depend on the output of the subprocess at the moment, so I don’t really get the bad-header warning (and there is no such problem when not launching the subprocess). The beginning of the plot-script looks like this:

import string
import sys
import os
from math import *
import tempfile
os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()
import matplotlib
matplotlib.use('Agg') 
import matplotlib.pyplot as matplot
from matplotlib import mpl

So far I only did rather simple plot with matplotlib and not as subprocesses, so I would really appreciate your help.

PS: I’m using ubuntu 11.04 and apache2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:27:34+00:00Added an answer on June 5, 2026 at 11:27 am

    I suspect that your plot script output stuff to stdout and apache is interpreting that as the headers it is expecting from the cgi.

    When you call the script with subprocess, redirect the output to dev null, like this

    from subprocess import Popen, STDOUT
    import os
    
    p = Popen(["ls","-l"], stdout=open(os.devnull, "w"), stderr=STDOUT)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a function that calls both plot() and legend() and it
I want to plot email from and to in world. For example, I received
i wrote a code that analyze a video file and then plot data on
Hi I am working on a script that will solve and plot an ODE
I want to write a bash script to automate the plotting of data, using
I want to make a daily profile plot: hour vs concentrations. I'm using matplotlib
I want to write a function that takes a dataframe, and graphs all the
I'm going to write a program that plots data from a sensor connected to
I want to print integer values to a file. I am able to write
I want to plot multiple rowstacked histograms on the same graph using gnuplot. A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.