title: VSCode: How to import a module from my code path to another file in the same path?
body: <p>I'm trying to debug my python app using VSCode. But I cannot configure my environment right. Attempting to import a class from one folder in my source path to another, gives me this message: </p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/mb/Library/source/sandbox/lib/lib.py", line 1, in &lt;module&gt;
      from app.main import MyClass
  ModuleNotFoundError: No module named 'app'
  </code></pre>
  
  <p>I created a simple app to exhibit the problem. My source path looks like this:</p>
  
  <pre><code>sandbox
  +-- .vscode
      --- launch.json
  +-- app
      --- __init__.py
      --- main.py
  +-- lib
      -- lib.py
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code># main.py
  
  class MyClass:
      def __init__(self):
          print('Creating object...')
      def print_message(self, message):
          print(message)
  </code></pre>
  
  <pre class="lang-py prettyprint-override"><code># lib.py
  
  from app.main import MyClass
  
  
  myclass = MyClass()
  myclass.print_message('hello, world!')
  </code></pre>
  
  <p>Trying to run <code>lib.py</code> using the default configuration to run current file I get the error message above.</p>
  
  <p>Additionally, I created a <code>.vscode/launch.json</code> to set the working directory, but to no avail. Here is my <code>launch.json</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>{
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
          {
              "name": "Python: Current File",
              "type": "python",
              "request": "launch",
              "program": "${file}",
              "console": "integratedTerminal",
              "cwd": "${workspaceFolder}"
          },
          {
              "name": "Python: Module",
              "type": "python",
              "request": "launch",
              "module": "main"
          }
      ]
  }
  </code></pre>
  
  <p>I'm sure, I'm missing a simple setup, but I can't put my finger on it.</p>
  
  <hr>
  
  <p><strong>Note</strong></p>
  
  <ul>
  <li>The interpreter used is: Python 3.7.5 64-bit</li>
  <li>The above code works fine in PyCharm.</li>
  <li>After some reading on VSCode documentation, I added <code>"env": {"PYTHONPATH": "${workspaceFolder}"}</code> to <code>launch.json</code>, but that didn't do any good.</li>
  <li>I also created a VSCode <em>task</em> to echo the <code>${workspaceFolder}</code> variable, and the output was stripped of all the <code>\</code> from the path, as if they were not escaped.
  Here is the task in <code>.vscode/tasks.json</code>:</li>
  </ul>
  
  <pre class="lang-js prettyprint-override"><code>{
      "version": "2.0.0",
      "tasks": [
        {
          "label": "workspaceFolder",
          "type": "shell",
          "command": "echo ${workspaceFolder}"
        }
      ]
    }
  </code></pre>
  
  <p>And here is the output that got from it:</p>
  
  <pre class="lang-sh prettyprint-override"><code>&gt; Executing task: echo C:\Users\mb\Library\source\sandbox &lt;
  
  C:UsersmbLibrarysourcesandbox
  
  Terminal will be reused by tasks, press any key to close it.
  </code></pre>