Questions tagged [vscode-python]

Questions about working with Python in Visual Studio Code using the Microsoft Python extension.

This VS extension makes VS Code a python IDE. Supports any operating system with most of Python interpreters. It provides IntelliSense, linting, debugging, and unit testing, environment switch using virtual and conda environments, etc.

127 questions
20
votes
2 answers

"Source file found twice" error with mypy>=0.780 in python for vscode

In my python project, after upgrading mypy from 0.770 to 0.782 an error is received in files where there were previously no type errors: my_pkg_name\__init__.py: error: Source file found twice under different module names: 'top_pkg.my_pkg_name' and…
stav
  • 1,497
  • 2
  • 15
  • 40
18
votes
1 answer

VS Code Python doesn't recognize match statement

When I use a match-case statement in Python in VS Code, it gives red squiggly lines and errors in the "problems" tab:
Tuor
  • 875
  • 1
  • 8
  • 32
18
votes
4 answers

How can I get pytest to not catch exceptions

When I run pytest in the vscode debugger with "Uncaught Exceptions" checked, and there are test errors, no uncaught exceptions occur, because pytest catches them do its results reporting. How can I tell pytest to just let the exceptions happen? So…
Philip
  • 1,691
  • 4
  • 21
  • 41
13
votes
1 answer

How to "Run all cells above" in VS Code's Python Notebooks

Is there a way to run all cells above a given cell in VS Code's python notebook working environment?
exan
  • 3,236
  • 5
  • 24
  • 38
13
votes
6 answers

VSCode on discover tests Error: spawn python ENOENT

I am running a python project in vscode with virtualenv. Python interpreter is set right. When I'm trying to discover tests it gives me an error saying python…
Bhavani Ravi
  • 2,130
  • 3
  • 18
  • 41
13
votes
3 answers

How to use PYTHONPATH with VSCode Python Extension for Debugging?

I'm working on a project which is structured like Parent Directory ----+ MyPackage ----__init__.py ----file1.py ----+ Tests ----test.py When I run the tests from terminal, I use PYTHONATH=./ python ./Tests/test.py Now, when I try…
v-i-s-h
  • 448
  • 1
  • 3
  • 12
11
votes
1 answer

Post-mortem debugging in vscode-python?

Python's post-mortem debugging (easily accessible by IPython's %debug magic) allows to step out of the exception's scope one or more times and view the variables as they were before the exception was thrown. Extremely useful. VSCode-python has nice…
Trisoloriansunscreen
  • 1,543
  • 1
  • 15
  • 27
9
votes
0 answers

VS Code Python TensorBoard integration doesn't work

The Python extension for VS Code recently released TensorBoard integration, but it doesn't seem to work for me. Whenever I run "Python: Launch TensorBoard" from the command palate, I get this screen. It's the TensorBoard page with the default…
8
votes
3 answers

Using Python or TypeScript to transform text that I select in VSCode

Let's say I select some text in the editor. I would like to define my own Python functions or scripts that: Take as an input the selected text as a string. Transform it and return a new string that replaces the selected text back in the…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
7
votes
1 answer

VS Code "Run selection/line in Python interactive window" not working at all

On a new install of VS Code on a new machine I have come across this error. The send to python interactive window functionality is behaving exceptionally weirdly. It will: - Send a single line of code to the interactive window using either…
7
votes
2 answers

vscode-python runs pytest in wrong directory such that relative paths get confused

With pytest and vscode-python I would like to run tests which were previously implemented with the unittest framework. Therefore, I successfully ran the tests using pytest in the respective directory tests. pytest I also set up vscode-python and…
r-beer
  • 121
  • 1
  • 1
  • 6
7
votes
3 answers

How to undo "Don't show this prompt again" in vscode python?

Accidentally selected "Don't show this prompt again" when prompted to install Pylint in VSCode Python. How should I undo/reset the action so the prompt will appear again?
djb
  • 71
  • 1
  • 2
6
votes
1 answer

vscode pylance type checking does not recognize re imports

When turning on "python.analysis.typeCheckingMode": "strict" or "python.analysis.typeCheckingMode": "basic", .py files containing imports of other modules do not recognize reimports and highlight them with errors: "Flow" is not exported from module…
6
votes
3 answers

VS Code - pylint is not running

I have a workspace setup in VS Code where I do python development. I have linting enabled, pylint enabled as the provider, and lint on save enabled, but I continue to see no errors in the Problems panel. When I run pylint via the command line in…
matthewmturner
  • 566
  • 7
  • 21
6
votes
1 answer

Install (Or suggest to) missing imported Python modules on VS Code like PyCharm does

When we import a module that isn't currently installed on the Python used on the current environment, PyCharm suggest us to 'install missing module', if you click install, it'll install it automatically... Is there any plugin for vscode that does…
Raul Chiarella
  • 518
  • 1
  • 8
  • 25
1
2 3
8 9