Showing results for 
Show  only  | Search instead for 
Did you mean: 

Calling Python script with shell_exec doesn't work, but works fine in command line

I have a collection of Python files I have uploaded into my public_html/cgi-bin folder. When I  SSH into my server via Terminal and run the scripts, everything works fine. But, when I use a shell_exec call in a PHP  script and call the script from my browser, the  output is null and filled with errors (e.g. ImportError).


Note that I have tried calling a simple python file that prints "hello world" and this works  correctly.


I am on a shared hosting  plan.


Any help would be appreciated!


Hey @sketchedin,


You may want to check your .htaccess file for some Python handlers like:

Options +ExecCGI
AddHandler cgi-script .py

If you're still seeing an issue, we'll need more details on what sort of script (or intended function) this is for? If you're not comfortable with sharing those details in this discussion so other members can try to help, then you'll want to try reviewing with our hosting team via phone or live chat. 


CG - GoDaddy | Community Moderator
24/7 support available at

Thank you for the response. I have added the recommended text to the .htaccess file in  public_html, but it doesn't seem to help.  The traceback says "import scipy ImportError: No module named scipy", but I know that scipy is installed and that it works through  SSH.


Any other ideas?