I need a php script to execute a python script. Now the python code looks like this:
test.py
import sys
try:
import numpy
print 'Numpy was loaded'
except:
print 'Could not Load Numpy'
All the following commands print 'Numpy was loaded':
$python test.py
$python2.7 test.py
PHP Script:
exec('python test.py',$output,$ret);
var_dump($output);
The PHP script works if the line 'import numpy' is removed.
I have tried the following things:
- Use absolute path in php script : exec("/usr/bin/python /home/pg/test.py"), exec("python2.7 test.py")
- Added absolute path of pwd and numpy using sys.path.append("path/to/numpy/dir where init.py is present")
It can be a user permission issue as well, but I have no idea.
EDIT
The exact error that python gives is :
"from numpy.linalg import lapack_lite"
ImportError: /opt/lampp/lib/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /lib/libgfortran.so.3