|
From: Scott S. <sco...@gm...> - 2013-12-04 10:04:32
|
On 3 December 2013 14:50, jilguero <jil...@gm...> wrote: > I am trying to make plots by using matplotlib.pyplot (within a Python > script) to be used in a web site (apache, and PHP). I am using Ubuntu > 12.04.3. The script works fine when run from the command line (it is able to > generate the image with "savefig"), but when the script doesn't work when > run from PHP under an apache request. I have found a similar problem in this > post: > http://matplotlib.1069221.n5.nabble.com/savefig-fails-under-apache-on-solaris-td15122.html > > Finally, I have found the solution in this web: > http://texnological.blogspot.com.es/2013/01/how-to-execute-python-matplolib-pylab.html > > The solution consists on importing matplotlib in this way: > # To import pylab > os.environ[ 'MPLCONFIGDIR' ] = '/tmp/' > import matplotlib > matplotlib.use('agg') > import pylab > > This works for me, but I don't know whether this is a bug and it has to be > reported anywhere. The best option should be to import it in a regular way > (such as import matplotlib.pyplot as plt), and this can be confusing for a > lot of people. Well, let me know. Thank you. Check out http://matplotlib.org/faq/howto_faq.html#matplotlib-in-a-web-application-server Cheers, Scott |