I am trying to activate my virtualenv using a php script or a python script but without using SSH.
This is to allow my website.com/something.py file to access certain libraries (if this can be done in another simpler way please let me know)
My PHP code is:
<?php
echo "A";
$result = exec("source ENV/bin/activate");
if ($result){
echo "Worked";
}
else{
echo "didnt work";
}
echo "B";
$result = system("python test.py");
?>
and I have test.py =
def main():
print "hello"
try:
import xlrd
except:
try:
print "xlrd didnt load"
import MySQLdb
except:
print "mdb,xlrd didnt load"
main()
The virtualenv I have setup has xlrd installed. This is the output I get on the webpage:
Adidnt workBhello xlrd didnt load
It makes sense that xlrd didnt load but why is the source command not working? This all works in SSH
sourceis not an executable, but a shell built-in.