title: Python Subprocess [Errno 2] No such file or directory when calling subprocess.run()
body: <p>I have a simple python web application made with flask. It compiles and runs the given c++ files on given input. Upon receiving the inputs from front-end, I use this function to compile and run the given file.</p>
  <pre><code>exec_id = get_unique_identifier(data[&quot;user_id&quot;])
  code = data[&quot;code&quot;]
  input_data = data[&quot;input&quot;]
  code_path = file_ops.write_code(code, data[&quot;lang&quot;], exec_id)
  logging.info(&quot;Code written to &quot;+code_path)
  #compile the code
  logging.info(&quot;Compiling the code&quot;)
  cmd = ['g++',code_path,'-o',exec_id]
  logging.info(&quot;Command is : &quot;+&quot; &quot;.join(cmd))
  try:
      compile_code=subprocess.run(cmd, stderr=PIPE)
      has_compiled = compile_code.returncode
  except Exception as e:
      return {&quot;status&quot;: &quot;server Error&quot;, &quot;output&quot; : e}
  compiled_file_path = './'+exec_id
  </code></pre>
  <p><code>file_ops.write_code</code> is a utility function which takes input code, extension as input and writes the code in a file in the same directory. The code runs alright in local environment, However, In production server with nginx, The code never gets compiled and I get the following error(After a big traceback)</p>
  <pre><code>[Errno 2] No such file or directory: 'g++'
  </code></pre>
  <p>I tried the following things</p>
  <ul>
  <li>Giving Absolute Path in code</li>
  <li>passing <code>shell=True</code> in subprocess.run</li>
  </ul>
  <p>Does this have something to do with Configuration with Nginx ? I'm running this application with gunicorn and nginx on Ubuntu VPS. If I run the code in development environment on vps, it runs without any error.</p>