Web & matplotlib

Hey,

I work with Mac OSX 10.7.2
I have a probleem. From the IDLE this little program works fine:
#!/usr/bin/python
import numpy
import matplotlib
print “Content-Type: text/plain\n”
print matplotlib.version

The output is:
Content-Type: text/plain

1.1.0

Starting this program from MAMP gives me: Internal Server Error

First I change the program into:
#!/usr/bin/python
import numpy
import matplotlib
print “Content-Type: text/plain\n”
print ‘No error’

But starting this program from MAMP also gives me: Internal Server Error

Now I change my program into:
#!/usr/bin/python
import numpy
##import matplotlib
print “Content-Type: text/plain\n”
print ‘No error’

Now starting this program from MAMP gives me: No error

So the import of mapplotlib causes this troubles. I don’t have these problems with the import of numpy.

Can someone help me with this problem?

I’m not sure what MAMP is. Usually this problem is because
matplotlib is trying to import a GUI toolkit and the windowing
environment is not available from the web server. Try setting the
matplotlib backend to “Agg”, by putting this at the top of the file:

   import matplotlib
   matplotlib.use("Agg")

Mike
···

http://p.sf.net/sfu/rsa-sfdev2dev1Matplotlib-users@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hello,

For what it is worth, I do the folllowing on my matplotlib scripts run
from apache on RHEL6.

import os
os.environ[ 'HOME' ] = '/tmp/'
os.environ[ 'USER' ] = 'nobody'

import matplotlib
matplotlib.use( 'Agg' )

This seems to keep matplotlib from bombing out when it attempts to
read dot files, etc.

daryl

···

On Mon, Nov 14, 2011 at 4:13 AM, Paul de Beurs <paul.debeurs@...287...> wrote:

Hey,

I work with Mac OSX 10.7.2
I have a probleem. From the IDLE this little program works fine:
#!/usr/bin/python
import numpy
import matplotlib
print "Content-Type: text/plain\n"
print matplotlib.__version__

The output is:
Content-Type: text/plain

1.1.0

Starting this program from MAMP gives me: Internal Server Error

First I change the program into:
#!/usr/bin/python
import numpy
import matplotlib
print "Content-Type: text/plain\n"
print 'No error'

But starting this program from MAMP also gives me: Internal Server Error

Now I change my program into:
#!/usr/bin/python
import numpy
##import matplotlib
print "Content-Type: text/plain\n"
print 'No error'

Now starting this program from MAMP gives me: No error

So the import of mapplotlib causes this troubles. I don't have these
problems with the import of numpy.

Can someone help me with this problem?

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options