title: Activating a Python virtual environment and calling python script inside another python script
body: <p>I am using pipenv for managing my packages. I want to write a python script that calls another python script that uses a different Virtual Environment(VE).</p>
  
  <p>How can I run python script 1 that uses VE1 and call another python script (script2 that uses VE2). </p>
  
  <p>I found this code for the cases where there is no need for changing the virtual environment. </p>
  
  <pre><code>import os
  os.system("python myOtherScript.py arg1 arg2 arg3") 
  </code></pre>
  
  <p>The only idea that I had was simply navigating to the target project and activate shell:</p>
  
  <pre><code>os.system("cd /home/mmoradi2/pgrastertime/")
  os.system("pipenv  shell")
  os.system("python test.py")
  </code></pre>
  
  <p>but it says:</p>
  
  <blockquote>
    <p>Shell for /home/..........-GdKCBK2j already activated.
      No action taken to avoid nested environments.</p>
  </blockquote>
  
  <p>What should I do now?
  in fact my own code needs VE1 and the subprocess (second script) needs VE2. How can I call the second script inside my code?</p>
  
  <p>In addition, the second script is used as a command line tool that accepts the inputs with flags:</p>
  
  <pre><code>python3 pgrastertime.py -s ./sql/postprocess.sql -t brasdor_c_07_0150  
  -p xml -f  -r ../data/brasdor_c_07_0150.object.xml 
  </code></pre>
  
  <p>How can I call it using the solution of @tzaman </p>