title: cannot import a module after os.chdir()
body: <p>I have a python file with the class <code>A</code> defined in it in a different directory than the one I am working in. I want to import a module from that class in my script. I wrote something like this in jupyter:</p>
  
  <pre><code>import os
  parent_dir = 'path/to/class'
  os.chdir(parent_dir) 
  from A import a
  </code></pre>
  
  <p>It works perfectly fine and I get to execute the program. However when I run the script in the same directory from the terminal, I get this error:</p>
  
  <pre><code>ModuleNotFoundError: No module named 'a'
  </code></pre>
  
  <p>I put a <code>os.getcwd()</code> before the error to make sure it is in the same directory, and when I go to that directory from the terminal and import the module directly there are no errors. I wonder why I get this error when running the script. </p>