I am getting an problem performing a Python script from the PHP script. My client uses Bluehost, and so i installed a 3rd party module (numpy) for Python using the easy_install method referred to here: https://my.bluehost.com/cgi/help/530?step=530

To show my problem, I have produced two python scripts along with a PHP script.

hello.py consists of:

print "Hello, World!"

hello-numpy.py consists of:

import numpy
print "Hello, World!"

The PHP script consists of:

Output from exec('python hello.py'): <?php echo exec('python hello.py'); ?><br>
Output from exec('python hello-numpy.py'): <?php echo exec('python hello-numpy.py'); ?><br>
Output from exec('whoami'): <?php echo exec('whoami'); ?>

Then i understand this output from PHP:

Output from professional('python hello.py'): Hello, World!
Output from professional('python hello-numpy.py'):
Output from professional('whoami'): venicetw

However, running these scripts in the SSH window yields the next results:

# python hello.py
Hello, World!
# python hello-numpy.py
Hello, World!
# whoami
venicetw

It appears PHP does not have any output once the Python script imports numpy, however it works fine from SSH. In addition, PHP will get coming back status of for hello.py but 1 for hello-numpy.py. I figured it may be a permissions problem, but both PHP and SSH are running because the "venicetw" user. An amount prevent PHP and Apache from obtaining the output in the Python script? Could it be something I'm able to consult with Bluehost, or something like that else I ought to check? We are using Apache 2.2.21, PHP 5.2.17, Python 2.4.3, and numpy 1.6.0.

Update: SSH prints the next Python pathways:

/home8/venicetw/public_html/venicenoise/python
/home8/venicetw/.local/lib/python2.4/site-packages/ogcserver-0.1.0-py2.4.egg
/home8/venicetw/.local/lib/python2.4/site-packages/PIL-1.1.7-py2.4-linux-x86_64.egg
/home8/venicetw/.local/lib/python2.4/site-packages/lxml-2.3.2-py2.4-linux-x86_64.egg
/home8/venicetw/.local/lib/python2.4/site-packages/WebOb-1.2b2-py2.4.egg
/home8/venicetw/.local/lib/python2.4/site-packages/PasteScript-1.7.5-py2.4.egg
/home8/venicetw/.local/lib/python2.4/site-packages/PasteDeploy-1.5.0-py2.4.egg
/home8/venicetw/.local/lib/python2.4/site-packages/Paste-1.7.5.1-py2.4.egg
/home8/venicetw/.local/lib/python2.4/site-packages/numpy-1.6.0-py2.4-linux-x86_64.egg
/home8/venicetw/.local/lib/python2.4/site-packages
/home8/venicetw/.local/lib/python/site-packages
/home8/venicetw/public_html/venicenoise/python
/usr/lib64/python24.zip
/usr/lib64/python2.4
/usr/lib64/python2.4/plat-linux2
/usr/lib64/python2.4/lib-tk
/usr/lib64/python2.4/lib-dynload
/usr/lib64/python2.4/site-packages
/usr/lib64/python2.4/site-packages/Numeric
/usr/lib64/python2.4/site-packages/PIL
/usr/lib64/python2.4/site-packages/gtk-2.0
/usr/lib/python2.4/site-packages

But Apache only prints these Python pathways:

/home8/venicetw/public_html/venicenoise/python
/usr/lib64/python24.zip
/usr/lib64/python2.4
/usr/lib64/python2.4/plat-linux2
/usr/lib64/python2.4/lib-tk
/usr/lib64/python2.4/lib-dynload
/usr/lib64/python2.4/site-packages
/usr/lib64/python2.4/site-packages/Numeric
/usr/lib64/python2.4/site-packages/PIL
/usr/lib64/python2.4/site-packages/gtk-2.0
/usr/lib/python2.4/site-packages

Solution: By performing /usr/bin/env from both PHP and SSH, I could determine that PHP didn't have an atmosphere variable for that Python path where numpy is installed. Within this situation, with the addition of

putenv('PYTHONPATH=/home8/venicetw/.local/lib/python2.4/site-packages:/home8/venicetw/.local/lib/python/site-packages:');

to the start of the PHP script, everything works not surprisingly.