I have searched thru all related questions, there are lots of similar ones, but my question is
how to call, from php, a python script in which I imported some non-standard libraries/modules
To be more specific, I have a .py file, test.py, in which I imported pycurl and bottlenose, which is an amazon API wrapper. Both module are not in the standard library. So the file looks like
import pycurl
import bottlenose
...
print "hello!"
Then I made a php file, test.php
<?
$output = array();
exec("/home/my_user_name/local/Python-2.7/bin/python test.py", $output, $ret_code);
var_dump( $output);
echo $ret_code;
?>
Both test.php and test.py are under the same directory. More importantly if I run
php test.php
in my terminal, there was no problem with with it. It sucessfully output "hello", and return code is 0, which means program exits with no error
However, when I tested it on my browser, www.someurl.com/test.php, some error occured. I tracked line by line and found the error occurs at the "import pycurl" and "import bottlenose".
I also tried to print out sys.path, it does include the path of bottlenose.
Can someone help?
Thanks!!