title: VS Code - pylinter cannot find module
body: <p>I started using VS Code for Python development on a Mac and cannot make <code>pylint</code> find a module. </p>
  
  <p>This is my project folder structure:</p>
  
  <pre><code>project_root/
     .env
     .vscode/
         settings.json
     lib/
         # lib containing necessary modules
     sample/
         client/
             EDAMTest.py
     # many more files
  </code></pre>
  
  <p>I use a virtualenv in which I have installed <code>pylint</code>. The virtual env is activated in the terminal. I started <code>code</code> from within <code>project_root</code> folder via <code>code .</code> in my terminal.</p>
  
  <p>VS Code says it is using the correct interpreter. I can see on the bottom left that it says <code>Python 3.6.1 (virtualenv)</code></p>
  
  <p>If I want to test the <code>project_root/sample/client/EDAMTest.py</code> code within terminal I can do it via <code>export PYTHONPATH=../../lib; python EDAMTest.py</code> while being in folder <code>project_root/sample/client/</code>.</p>
  
  <p>Now if I am in VS Code, open the file <code>EDAMTest.py</code>, <code>pylint</code> is telling me that it cannot import modules from <code>lib</code>.</p>
  
  <p>Now my question:</p>
  
  <p>How can I add <code>lib</code> to <code>PYTHONPATH</code> in VS Code?</p>
  
  <p>I found several possible ways to do so:</p>
  
  <ol>
  <li>Create a <code>.env</code> file (see [1] below).</li>
  <li>Specify <code>PYTHONPATH</code> in <code>.vscode/launch.json</code> file (see [2])</li>
  </ol>
  
  <p>None of the possible solutions I found seem to work.</p>
  
  <p>What am I missing?</p>
  
  <hr>
  
  <p>[1] <a href="https://code.visualstudio.com/docs/python/environments#_environment-variable-definitions-file" rel="noreferrer">Environment variable definitions file</a></p>
  
  <p>This tells me how to define global (env) vars. So I specified this:</p>
  
  <p><code>PYTHONPATH="~/.virtualenvs/evernote/bin/python;lib"</code></p>
  
  <p>But it won't work. Still <code>lib</code>s path is not found by <code>pylint</code></p>
  
  <hr>
  
  <p>[2] So I did create a <code>launch.json</code> file like so:</p>
  
  <pre><code>{
      "name": "Python",
      "type": "python",
      "request": "launch",
      "stopOnEntry": false,
      "pythonPath": "${config.python.pythonPath}",
      "program": "${file}",
      "cwd": "${workspaceRoot}",
      "debugOptions": [
          "WaitOnAbnormalExit",
          "WaitOnNormalExit",
          "RedirectOutput"
      ],
      "env": {
          "PYTHONPATH": "~/.virtualenvs/evernote/bin/python:lib"
      }
  }
  </code></pre>
  
  <h2>---</h2>
  
  <p>EDIT</p>
  
  <p>Here is a link that tries to address this problem:</p>
  
  <p><a href="https://code.visualstudio.com/docs/python/linting#_troubleshooting-linting" rel="noreferrer">Troubleshooting linting</a></p>
  
  <p>That link tries to address several possible problems, one is this:</p>
  
  <blockquote>
    <p>... unable to import </p>
  </blockquote>
  
  <p>The suggested solution is:</p>
  
  <blockquote>
    <p>Ensure that the <code>pythonPath</code> setting points to a valid Python installation where Pylint is installed. </p>
  </blockquote>
  
  <p>=> Yes, I did.</p>
  
  <blockquote>
    <p>Alternately, set the <code>python.linting.pylintPath</code> to an appropriate version of Pylint for the Python interpreter being used.</p>
  </blockquote>
  
  <p>=> I did, still no success:</p>
  
  <p>My <code>.vscode/settings.json</code>:</p>
  
  <pre><code>{
      "python.pythonPath": "~/.virtualenvs/evernote/bin/python",
      "python.linting.pylintPath": "~/.virtualenvs/evernote/bin/pylint"
  }
  </code></pre>