title: 'Import "Path.to.own.script" could not be resolved Pylance (reportMissingImports)' in VS Code using Python 3.x on Ubuntu 20.04 LTS
body: <p>It is a <a href="https://stackoverflow.com/a/61383869/12298276">similar situation I'd encountered</a> several months ago using <a href="https://www.pylint.org/" rel="noreferrer">pylint</a> prior to <a href="https://github.com/microsoft/pylance-release" rel="noreferrer">pylance</a>:</p>
  <p>My <code>python 3.9x</code> - script (using <code>VS Code</code> on <code>Ubuntu 20.04 LTS</code>) starts with the following import of custom &quot;tools&quot;:</p>
  <pre><code>import sys
  sys.path.append(
      '/home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts/'
  )
  
  import General.Misc.general_tools as tools
  </code></pre>
  <p>Now, <code>Pylance</code> states:</p>
  <pre><code>Import &quot;General.Misc.general_tools&quot; could not be resolvedPylance (reportMissingImports)
  </code></pre>
  <p>This happens even though during the program execution the module is being imported perfectly fine.</p>
  <p>Thus, to ensure making <code>Pylance</code> understand that this is an existing module-path, in addition to the <code>sys.path.append(..)</code> - approach, I added the following to the <code>settings.json</code> - file:</p>
  <pre><code>{
      ...
      // Possible values: &quot;Jedi&quot;, &quot;Pylance&quot;, &quot;Microsoft&quot;, &quot;None&quot;.
      &quot;python.languageServer&quot;: &quot;Pylance&quot;,
      // NOTE on changing from microsoft to pylance language server: python.autoComplete.extraPaths --&gt; python.analysis.extraPaths
      // Docs: https://github.com/microsoft/pylance-release/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings
      &quot;python.analysis.extraPaths&quot;: [
          &quot;/home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts&quot;
      ],
      ...
  }
  </code></pre>
  <p>Yet, I still get the <code>reportMissingImports</code>-message even though it's correctly being imported.</p>
  <p>A workaround I found <a href="https://www.reddit.com/r/VisualStudioCode/comments/i3mpct/how_to_tell_pylance_to_ignore_particular_linefile/g5bkx9u?utm_source=share&amp;utm_medium=web2x&amp;context=3" rel="noreferrer">here</a> works well (appending <code># type: ignore</code> to the import-statement):</p>
  <pre><code>import General.Misc.general_tools as tools  # type: ignore
  </code></pre>
  <p>Nevertheless, it's just a workaround which is why I'm looking to solve the root of this issue. Technically, it is <a href="https://stackoverflow.com/a/61383869/12298276">the same workaround</a> I employed earlier to get rid of similar warning messages from <code>pylint</code>. Probably it's something inherent to the <code>VS-Code</code> <code>settings.json</code> - configuration, since using <code>VS-Code</code> is the constant factor here.</p>
  <hr />
  <p><strong>EDIT on additional measures which didn't resolve the problem:</strong></p>
  <p>I added</p>
  <pre><code>export PYTHONPATH=&quot;$PYTHONPATH:/home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts&quot;
  </code></pre>
  <p>to my <code>~/.bashrc</code> - file, which enables me now to import the module directly in a <code>python</code>-shell from terminal without the previous <code>sys</code>-path manipulation. This however applies only to the global system python environment, but not to any virtual environment.
  In order to change the sys-path there, I followed <a href="https://stackoverflow.com/a/15282950/12298276">these instructions</a>, while my particular virtual environment &quot;scrapy_course&quot; is open, like so:</p>
  <pre><code>(scrapy_course) andylu@andylu-Lubuntu-PC:~/$ add2virtualenv /home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts
  </code></pre>
  <p>This command applies for <a href="https://virtualenvwrapper.readthedocs.io/en/latest/" rel="noreferrer">virtualenvwrapper</a>, which mananges virtual environments in conjunction with <a href="https://github.com/pyenv/pyenv" rel="noreferrer">pyenv</a> neatly.
  Now, I can run my aforementioned script within the current environment even without the <code>sys.path.append(...)</code> prior to import the module, YET <code>pylance</code> still doesn't recognize the paths correctly and shows me the same warning as before.</p>
  <hr />
  <p><strong>EDIT on <code>&quot;python.analysis.useImportHeuristic&quot;: true</code>:</strong></p>
  <p>I've had this option constantly activated in my global <code>settings.json</code> - file and still I didn't notice any effect. I will keep you updated once this should change, or finally a (different) solution crosses my way.</p>
  <hr />
  <p><strong>EDIT on suppressing/disabling the Pylance 'reportMissingImports' linting-message:</strong></p>
  <p>I've found out <a href="https://stackoverflow.com/a/68210700/12298276">how to suppress a specific Pylance-linting-message</a> altogether, if that is of your interest as a workaround. Especially in my current situation, I need to utilize <a href="https://www.pylint.org/" rel="noreferrer">pylint</a> in <a href="https://github.com/microsoft/vscode-python/issues/13315#issuecomment-701913450" rel="noreferrer">parallel </a> anyway, so I don't depend on Pylance's linter at all.</p>