Can I prevent the Cmd dialogue from popping up when using SymPy preview?
<p>I have written some code in Python 2.7 that will read a string from a .ini file and generate a .png image of the string in LaTeX format using <code>sympy.preview</code>. The idea is to use this script to generate the images in the background while I am typing them out. The problem is that even when I run the script in the background (using pythonw.exe), two empty command line windows will pop up for <code>latex.exe</code> and <code>dvipng.exe</code> and close immediately. This is annoying because it interrupts my typing. I want to be able to do it "on the fly" without being interrupted.</p>

<p>Is there a way to prevent these windows from opening?</p>

<p>Here is my minimum working example:</p>

<pre><code>from sympy import preview   # for generating Latex images
import ConfigParser         # for reading .ini files

# read the latex commands from the .ini file:
config = ConfigParser.RawConfigParser()

config.read('mathPredictor.ini')
one = config.get('Words', 'one')

prefix = '\\Huge $' # make the Latex equations bigger
suffix = '$'
eqone =  prefix + one + suffix

# for generating Latex images:
preview(eqone, viewer='file', filename='one.png', euler=False)
</code></pre>

<p>for the .ini file</p>

<pre><code>[Words]
one=\alpha
</code></pre>

<p>I am running Windows 8 64-bit with Python 2.7.10. This question is cross-posted at <a href="http://tex.stackexchange.com/questions/330876/">tex.SE</a>.</p>

<p>I solved my own problem. If I ran the Python script from a previously-existing cmd instance, the windows didn't pop up. My solution then was to start a hidden instance of cmd and send the path location to the hidden cmd window. This enabled the Python code to be executed without the annoying popups from <code>latex.exe</code> and <code>dvipng.exe</code>. </p>

<p>I accomplished this in Autohotkey language using the following function:</p>

<pre><code>Run, %comspec%, , max, pid2  ; runs cmd in hidden mode with instance name given by %pid%
WinWait, ahk_pid %pid2%  ; waits for instance to be active
ControlSend, ,python mypythonscript.py`r, ahk_pid %pid2%  ; send text for script execute
</code></pre>

python latex command-prompt sympy