title: Change Directory and Execute Command - Python
body: <p>I have been struggling a lot with this piece of code i wrote by referring tutorials:</p>
  <pre><code>    import os
      os.chdir(f'/home/django/image-io/accounts/john_doe/optimized/')
      cwd = os.getcwd()
      logger.info(f'CURRENT WORKING DIRECOTRY :{cwd}')
      subprocess.Popen(f&quot;optimize-images&quot;)
  </code></pre>
  <p>What i am trying to do is dynamically change directory on username (john_doe) in this case and run a command optimize-images inside that directory to optimize all images .</p>
  <p>It doesn't seem to work.</p>
  <p>When i checked the logs , it says:</p>
  <blockquote>
  <p>optimize-images : &quot;No such directory present&quot;</p>
  </blockquote>
  <p>I am not able to understand , where i am doing wrong. any help would be appreciated.</p>