title: ModuleNotFoundError: No module named '####' when running .py script in command line
body: <p>Here's the simplified demo.</p>
  <pre><code>project-dir
      |__dir1
           |__dir2
                |__mod1
                |    |__func1.py
                |    |__func2.py
                |__a.py
                |__b.py
  </code></pre>
  <pre><code># /dir1/dir2/mod1/func1.py
  def bar():
      print('this is func `bar` in `func1`')
  </code></pre>
  <pre><code># /dir1/dir2/mod1/func2.py
  def foo():
      print('this is func `foo` in `func2`')
  </code></pre>
  <pre><code># /dir1/dir2/b.py
  def spam():
      print('this is func `spam` in `b`')
  </code></pre>
  <pre><code># /dir1/dir2/a.py
  from dir1.dir2.b import spam
  from dir1.dir2.mod1.func1 import bar
  from dir1.dir2.mod1.func2 import foo
  
  if __name__ == '__main__':
      print('this is `a`)
      spam()
      bar()
      foo()
  </code></pre>
  <p>When I run this script <code>a.py</code> in command line as <code>D:\project-dir&gt;python dir1/dir2/a.py</code>, the error <code>ModuleNotFoundError: No module named 'dir1'</code> occurs. But it works out when running this script <code>a.py</code> directly in IDE. How to correctly run this script in command line ?</p>