title: 'pdflatex' not found in subprocess within a bundled PyInstaller APP
body: <p>I am attempting to create a macOS standalone app from a <code>PyQt5</code> GUI using <a href="https://pyinstaller.org/en/stable/" rel="nofollow noreferrer">PyInstaller</a>. All works apart from automatically generating a PDF from a TEX file using the <a href="https://pypi.org/project/pdflatex/" rel="nofollow noreferrer">pdflatex</a> module (in conjunction with <a href="https://jeltef.github.io/PyLaTeX/current/" rel="nofollow noreferrer">Pylatex</a>).</p>
  <p>Both the <code>pylatex</code> and <code>pdflatex</code> modules require calling the <a href="https://docs.python.org/3/library/subprocess.html" rel="nofollow noreferrer">subprocess</a> module, which is done as following:</p>
  <pre><code>fp = subprocess.run(args, input=self.latex, env=env, timeout=15, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  </code></pre>
  <p>Where <code>args=['pdflatex', '-output-directory=/Users/Desktop', '-interaction-mode=batchmode', '-jobname=test'] </code></p>
  <p>This however does not work within the bundled app as it is crashing with the following error which I am logging to a file:</p>
  <pre><code>[Errno 2] No such file or directory: 'pdflatex' 
  </code></pre>
  <p>Evidently, the <code>pdflatex</code> executable isn't being included/ found in the bundle. Running <code>which pdflatex</code> in the terminal outputs the following directory: <code>/Library/TeX/texbin/pdflatex</code> So I have tried to add the path with the following PyInstaller command:</p>
  <pre><code>pyinstaller --noconsole --onefile --path &quot;/Library/TeX/texbin&quot; main.py
  </code></pre>
  <p>But the app still cannot find the <code>pdflatex</code> executable at runtime, whereas the terminal executable works without issues. I have exhausted all similar posts online and ran out of things to try so I was hoping someone might guide me to the solution.</p>
  <p>Related info:</p>
  <ul>
  <li>macOS version: 10.13.6 High Sierra</li>
  <li>Python: 3.8</li>
  <li>PyInstaller: 5.1</li>
  </ul>