Matplotlib import issues in PHP

I'm having issues importing matplotlib into my python script, but only when runing under PHP.

The line:
    from matplotlib import *

causes my .py script to return an error code "1" when being called from inside a PHP script. However, the script runs just fine when called from the command line.

If i comment out the above line and all the matplotlib-related commands in my script, it will run just fine (but without plots of course). But the include command alone is enough to cause an error 1 return.

I have been through every documentation source I can find, I've tried every variation of import i can think of, and I've come up with a big fat 0. I've tried something like:
    sys.path.append("/usr/lib/python2.3/site-packages/matplotlib")
after the sys import and before the matplotlib import thinking there was a path issue with the apache user, and got jack squat out of that.

Has anyone else had issues calling python scripts from inside PHP? All my other imports below:
# Module Imports
from optparse import OptionParser
import sys
#from matplotlib import *
from os import listdir
from string import split
from array import array
from time import time#, ctime

work just fine. I've been on this for 3 solid days, someone either shoot me or help me! Thanks.

My guess would be that it is a permission issue from running udner apache.. did you look at your apache error log files? What os are you using? Can you run this script under apache directly (as cgi say) instead of calling it throught php? I remember that I had to manually change some permissions on some of the matplotlib (or maybe the font packages that come with it) stuff to get things running...

Peter

Jonathan Hanson wrote:

···

I'm having issues importing matplotlib into my python script, but only when runing under PHP.

The line:
   from matplotlib import *

causes my .py script to return an error code "1" when being called from inside a PHP script. However, the script runs just fine when called from the command line.

If i comment out the above line and all the matplotlib-related commands in my script, it will run just fine (but without plots of course). But the include command alone is enough to cause an error 1 return.

I have been through every documentation source I can find, I've tried every variation of import i can think of, and I've come up with a big fat 0. I've tried something like:
   sys.path.append("/usr/lib/python2.3/site-packages/matplotlib")
after the sys import and before the matplotlib import thinking there was a path issue with the apache user, and got jack squat out of that.

Has anyone else had issues calling python scripts from inside PHP? All my other imports below:
# Module Imports
from optparse import OptionParser
import sys
#from matplotlib import *
from os import listdir
from string import split
from array import array
from time import time#, ctime

work just fine. I've been on this for 3 solid days, someone either shoot me or help me! Thanks.

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I did some python CGI scripting at one point, and I needed to do something like

os.environ['MATPLOTLIBDATA'] = '/where/matplotlib/lives'

before the matplotlib import ... hope that helps,

rodrigo

···

---

Rodrigo Caballero Augi (Rodrigo Caballero)
Research Associate
Department of the Geophysical Sciences, University of Chicago
5734 South Ellis Avenue, Chicago, IL 60637, USA.

On Thursday, July 8, 2004, at 06:26 PM, Jonathan Hanson wrote:

I'm having issues importing matplotlib into my python script, but only when runing under PHP.

The line:
   from matplotlib import *

causes my .py script to return an error code "1" when being called from inside a PHP script. However, the script runs just fine when called from the command line.

If i comment out the above line and all the matplotlib-related commands in my script, it will run just fine (but without plots of course). But the include command alone is enough to cause an error 1 return.

I have been through every documentation source I can find, I've tried every variation of import i can think of, and I've come up with a big fat 0. I've tried something like:
   sys.path.append("/usr/lib/python2.3/site-packages/matplotlib")
after the sys import and before the matplotlib import thinking there was a path issue with the apache user, and got jack squat out of that.

Has anyone else had issues calling python scripts from inside PHP? All my other imports below:
# Module Imports
from optparse import OptionParser
import sys
#from matplotlib import *
from os import listdir
from string import split
from array import array
from time import time#, ctime

work just fine. I've been on this for 3 solid days, someone either shoot me or help me! Thanks.

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

You can always do this by adding:

SetEnv PYTHONPATH /locations/of/packages/want/to/import/

to your apache config file.

···

--
Peter Groszkowski Gemini Observatory
Tel: +1 808 974-2509 670 N. A'ohoku Place
Fax: +1 808 935-9235 Hilo, Hawai'i 96720, USA

Rodrigo Caballero wrote:

I did some python CGI scripting at one point, and I needed to do something like

os.environ['MATPLOTLIBDATA'] = '/where/matplotlib/lives'

before the matplotlib import ... hope that helps,

rodrigo

---

Rodrigo Caballero Augi (Rodrigo Caballero)
Research Associate
Department of the Geophysical Sciences, University of Chicago
5734 South Ellis Avenue, Chicago, IL 60637, USA.

On Thursday, July 8, 2004, at 06:26 PM, Jonathan Hanson wrote:

I'm having issues importing matplotlib into my python script, but only when runing under PHP.

The line:
   from matplotlib import *

causes my .py script to return an error code "1" when being called from inside a PHP script. However, the script runs just fine when called from the command line.

If i comment out the above line and all the matplotlib-related commands in my script, it will run just fine (but without plots of course). But the include command alone is enough to cause an error 1 return.

I have been through every documentation source I can find, I've tried every variation of import i can think of, and I've come up with a big fat 0. I've tried something like:
   sys.path.append("/usr/lib/python2.3/site-packages/matplotlib")
after the sys import and before the matplotlib import thinking there was a path issue with the apache user, and got jack squat out of that.

Has anyone else had issues calling python scripts from inside PHP? All my other imports below:
# Module Imports
from optparse import OptionParser
import sys
#from matplotlib import *
from os import listdir
from string import split
from array import array
from time import time#, ctime

work just fine. I've been on this for 3 solid days, someone either shoot me or help me! Thanks.

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options