On 3 December 2013 14:50, jilguero <jilguero...@gmail.com> 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

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to