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
3
votes
1 answer

How to ignore Python interactive window for linting in VSCode

I would like to disable linting for cells in the interactive window in Visual Studio Code. I don't see how it is beneficial, since it is not possible to manipulate cells which have already been run (which is different from *.ipynb notebooks). I…
Richard
  • 709
  • 1
  • 6
  • 15
3
votes
0 answers

Any way to pause only one thread while debugging Python in vscode?

When I debug a multi-threaded Python program using vscode, I found all threads were suspended when a breakpoint is hitted. Is there any way to choose to suspend only one thread or all like what Pycharm does?
3
votes
3 answers

In VS Code, how can I get the path to the currently selected Python?

I want to specify the Python path in tasks.json without an explicit full path. I used to do this using python.pythonPath, but that setting is now deprecated. What is the alternative way to retrieve the currently selected Python path? Are there any…
Du Shiqiao
  • 377
  • 1
  • 9
3
votes
0 answers

how to debug unittest in vscode using pytest

I am trying to use vscode to debug some unit tests using pytest. One special thing is I am importing the module I need to test from another folder. src func.py test test_func.py so inside test_func.py, I imported the function I need to…
derek
  • 9,358
  • 11
  • 53
  • 94
3
votes
1 answer

How can I set a path to setup.cfg in vs-code for its python plugin?

I have a development directory in which a python package is kept as a sub-directory. The package itself does not ship a setup.cfg, however, I like to have some development related settings which I do not want to push to the package, therefore I keep…
E.Eisbrenner
  • 143
  • 1
  • 10
2
votes
0 answers

How can I prioritize "Add import" over "Ruff: Disable" in Python / VS Code

I'm writing Python code in VS Code and have recently installed the Ruff linter and its associated VS Code extension. One thing I'm finding frustrating is that when I write a symbol name and want to use VS Code's "Quick Fix" to add an import for it,…
danvk
  • 15,863
  • 5
  • 72
  • 116
2
votes
2 answers

Why is Visual Studio Code not showing mypy errors when I have my package installed in editable mode in a venv?

I have a Python project which uses mypy for type checking. The root of my project contains a setup.py and the package folder rise, along with a virtual environment folder venv. Both my shells and VSCode are set to use this virtual environment. Most…
Soren Bjornstad
  • 1,292
  • 1
  • 14
  • 25
2
votes
1 answer

Where does VS Code function signature IntelliSense come from for Python?

If I import the requests Python library (for example) and hover over requests.get I see this: See how the function signature parameters and types are described in detail? Now, if I Ctrl+Click on the get method, I am taken to my local…
2
votes
1 answer

VSCode python debugger fails to attach to local port with ECONNREFUSED

I'm trying to debug locally a project that is deployed on Microsoft Azure. I have a copy of the repository on my PC and setup the launch.json file as: { "version": "0.2.0", "configurations": [ { "name": "Attach to…
Luca
  • 1,610
  • 1
  • 19
  • 30
2
votes
1 answer

why vscode automatically get python version 3.7.3 instead of 3.10.4?

I uninstall python 3.7.3 64-bit and installed python 3.10.4 64-bit on windows. but every time I launch vscode it automatically gets the 3.7.3 version even after I uninstall it. and it shows python 3.7.3 global. after uninstalling 3.7.3 from the…
Archode
  • 37
  • 1
  • 8
2
votes
0 answers

How do I "post mortem" a "Caught Exception" in Python in VS.Code?

In VS.Code with the Python extension, I can break on "Uncaught Exceptions" and "Raised Exceptions". But what if I don't want to break on all exceptions, only those that are uncaught in a certain function? (but which are caught, say by a framework…
LeoRochael
  • 14,191
  • 6
  • 32
  • 38
2
votes
1 answer

How do I have VS Code only autocomplete names in Python?

Recently (currently on 1.58.2), it seems like VS Code became far more "helpful" when autocompleting names. Before, I could type Then when hitting Tab I'd end up with except pydantic.ValidationError but now in cases from built-ins like int to third…
Nick T
  • 25,754
  • 12
  • 83
  • 121
2
votes
1 answer

VSCODE pytest not constructing sys.path the same as command line pytest

I am getting an import error when running pytest using VSCODE python extension. I don't get the error when running pytest from the command line. I have a python 2.7 project with the below setup. provision/ |-- venv/ |-- requirements.txt |--…
JoeG
  • 21
  • 1
2
votes
1 answer

Run single folder of pytest tests in vscode

I have a sort of a "micro-service" Python repo with a setup similar to the following: sample ├── bar │ ├── src │ │ └── main.py │ └── tests │ └── test_main.py ├── foo │ ├── src │ │ └── main.py │ └── tests │ └──…
swigganicks
  • 1,109
  • 2
  • 14
  • 28
2
votes
1 answer

Error: spawn ENOTDIR, when selecting python interpreter in VS Code

I have created django project and virtualenv into same folder as opening-up vscode does not display the virtual environment in which the django project is using. now if I select interpreter for the project I get
Avin Mathew
  • 336
  • 11
  • 25
1 2
3
8 9