title: Unable to execute Python script from PHP shell_exec
body: <p>I'm trying to execute a python (Python 3) script from the PHP <code>shell_exec</code>function but it doesn't seem to be working, I'm trying it on a windows system but it will be in CentOS 7 in production.</p>
  
  <p>In the below code snippet nothing happens when the PHP runs. But it I use the <code>$response = shell_exec("php -v");</code> line it displays the PHP version ok. I've also tried running the python script directly on the command line and it runs fine with no errors.</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>    $command = "\"C:\Programs\Python\Python36-32\python.exe\" \"E:\\htdocs\\dev\\_nodes\\jobs\\jobCheck.py\" \"https:/www.google.ie\" 1";
      $response = shell_exec($command);
      //$response = shell_exec("php -v");
      echo $response;
  </code></pre>
  
  <p><strong>Command Line</strong></p>
  
  <pre><code>"C:\Programs\Python\Python36-32\python.exe" "E:\\htdocs\\dev\\_nodes\\jobs\\jobCheck.py" "https:/www.google.ie" 1
  </code></pre>
  
  <p><strong>Update #1</strong></p>
  
  <p>I've gotten the python script to run via PHP, but the python script crashes once it hits <code>driver = webdriver.PhantomJS()</code>, the import exists in the python script <code>from selenium import webdriver</code> and all this functionality works fine once called directly via the command line but doesn't seem to work once the python script is called from PHP.</p>
  
  <p>Here's a sample script that prints out <code>test 1</code> but not <code>test 2</code> when called from the PHP script.</p>
  
  <pre><code>from selenium import webdriver
  
  print("test 1")
  
  driver = webdriver.PhantomJS()
  
  print("test 2")
  
  driver.quit()
  </code></pre>
  
  <p><strong>Update #2</strong></p>
  
  <p>Looks like it was an issue with paths, there is a file created in the python script that was using a relative path, once I changed the path to be a full path the script ran ok both in the command line and when being called via the PHP script.</p>