title: How to convert .py file to .exe hiding the console (based on another stackoverflow's post)
body: <p>I tried several ways to convert a <code>.py</code> file to a <code>.exe</code>, but it always gave me the same problem, namely that the <code>.exe</code> file didn’t work. I found a solution thanks to <a href="https://stackoverflow.com/questions/41570359/how-can-i-convert-a-py-to-exe-for-python">this post</a>, but it is not specified how to hide the console. Could someone check the post and tell me how to do it?</p>
  <p>EDIT:</p>
  <p>After searching I found out a solution for my problem:</p>
  <pre><code>import cx_Freeze
  
  exe = [cx_Freeze.Executable(&quot;game.py&quot;, base = &quot;Win32GUI&quot;)] # &quot;Win32GUI&quot; -&gt; no console
  
  packages = [&quot;os&quot;, &quot;time&quot;, &quot;random&quot;, &quot;io&quot;, &quot;pygame&quot;, &quot;base64&quot;, &quot;paho.mqtt&quot;]
  
  cx_Freeze.setup(
      name = &quot;ForzaQuattro&quot;,
      version = &quot;1.0&quot;,
      options = {&quot;build_exe&quot;: {&quot;packages&quot;: packages,  
          &quot;include_files&quot;: []}},
      executables = exe
  ) 
  </code></pre>
  <p>I used cx_Freeze with the param <code>base=&quot;Win32GUI&quot;</code>, this will hide the console of the exe file.</p>
  <p>After that you will just replace <code>game.py</code> with the name of your python script, replace <code>packages</code> with the package that you need, save that file as <code>setup.py</code> and run by command prompt <code>python setup.py build</code>.</p>
  <p>That will genarate a directory with all what you need.</p>