I am trying to activate my virtualenv using php script or python script, but without using SSH.
This will allow my website.com/something.py file to access specific libraries (if you can do it in another easy way, 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 virtual machine I installed has xlrd installed. This is the result I get on the webpage:
Adidnt workBhello xlrd didnt load
It makes sense that xlrd did not load, but why does the source command not work? It all works in SSH
source share