title: Automatization of third party libraries in python with PowerShell or CMD
body: <p>If I want to run my Python 3.8 program in Windows 10, I have to firstly load below commands in PowerShell:</p>
  <pre><code>PS&gt; cmd
  CMD&gt; call [somePath]/environmentSettingScript.bat
  CMD&gt; set Path=%Path%;D:[someOtherPath]\win64
  </code></pre>
  <p>After that, I am able to run Python in the same window (still CMD running in PS) and load my third party libraries.</p>
  <pre><code>CMD&gt; python
  &gt;&gt;&gt; from thirdPartyLibrary import something
  </code></pre>
  <p>or</p>
  <pre><code>CMD&gt; python programThatUseThirdPartyLibrary.py
  </code></pre>
  <p>Of course, it works also, if I make <code>call</code> and <code>set</code> procedures from first snippet directly in CMD. Nevertheless, I don't like such kind of solutions. I want to automatize this procedure, in programThatUseThirdPartyLibrary.py code directly with Spyder IDE usage. To do this I try write something like that:</p>
  <pre><code>import subprocess
  
  pipe = subprocess.Popen(r&quot;cmd \c call [somePath]/environmentSettingScript.bat \c set Path=%Path%;D:[someOtherPath]\win64&quot;, 
                          stdin = subprocess.PIPE, 
                          stdout = subprocess.PIPE, 
                          stderr = subprocess.PIPE, 
                          encoding='utf8',
                          shell=True)
  stdout, stderr = pipe.communicate()
  print(&quot;No stderr&quot; if pipe.returncode == 0 else &quot;Some stderr&quot;)
  
  from thirdPartyLibrary import something
  </code></pre>
  <p>Unfortunately, <code>stdout</code> shows only the information about loading first line of <code>cmd</code> command:</p>
  <pre><code>Microsoft Windows [Version 10.0.17763.1697]
  (c) 2018 Microsoft Corporation. All rights reserved.
  
  D:\[workDir]&gt;
  </code></pre>
  <p>and it looks like, that the rest of commands stuck in the pipe. I am quite confused, because <code>print()</code> and <code>stderr</code> shows that, everything goes ok - but <code>import</code> at the end of the script fails with error</p>
  <pre><code>ModuleNotFoundError: No module named thirdPartyLibrary 
  </code></pre>