1

I am getting a unresolved import 'sys' linter warning in my VSCode Python program. I have other imports (json, numpy, etc.) that I don't have any issue with. I am using all the latest versions of Python, VSCode, and the extensions. It doesn't matter which linter I use, they all give me the same error. However, when I run the file it runs with no problem. Why is this happening and how can I fix it?

EDIT:

At the bottom in the PROBLEMS pane it says unresolved import 'sys' Python(unresolved-import)

Here is what pops up in VSCode when I put my cursor over sys:

(module) "/root/.vscode-server/extensions/ms-pyright.pyright-1.0.57/typeshed-fallback/stdlib/3/sys.pyi"
unresolved import 'sys'Python(unresolved-import)
Peek Problem
No quick fixes available```
jss367
  • 4,759
  • 14
  • 54
  • 76

2 Answers2

0

Based on your description my suspicion is the warning is coming from the Microsoft language server (unfortunately you didn't provide the exact problem output which specifies what tool is providing the warning). If it is the language server then it's fixed in the beta release and thus will get fixed in stable eventually.

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • I updated my question with the error information. It looks like it's coming from the Pyrite plugin. – jss367 Aug 26 '19 at 23:47
0

You may be able to find a solution in an answer like this one on setting up your Python Path in VS Code.

Another solution is to add your desired python interpreter installation folder to the PYTHONPATH environment variable.

That said, it does appear when you do not have a virtual environment setup (venv) this is a bug that will be fixed, per Brett's answer.

LightCC
  • 9,804
  • 5
  • 52
  • 92