143 questions
1
vote
1
answer
81
views
VS Code hangs at Pytest discovery
I'm having issues with getting VS Code to integrate Pytest discovery, where it just hangs indefinitely on discovering tests for the workspace. I've tried about every solution, and I have a minimal ...
3
votes
2
answers
221
views
Why won't VSCode Smart Send my Python code line by line to the terminal as it used to?
I generally just run my Python code line-by-line using the Python Smart Send feature on VSCode, but after I was away from work for a bit, it suddenly stopped working. Normally Shift + Enter or Right ...
0
votes
0
answers
112
views
Pausing or adding new breakpoints halfway during running in VSCode makes the Python Exception uncaught, unhandled, and lost
Pausing or adding new breakpoints halfway during debugging in VSCode seems to make the Python Exception uncaught.
The following is a minimal example to reproduce my problem.
import contextlib, signal
...
1
vote
1
answer
92
views
Multiple Python Paths
I have multiple Python Paths to choose from as seen in the images. I remember installing Python via brew and through the internet and Anaconda.
I don't have any idea which are redundant and what to ...
0
votes
0
answers
91
views
Can't deactivate python venv on vscode after recent update
I've recently updated vscode to the most recent version, and whenever I open up a new shell or cmd it activates the venv in that directory, and that's fine and expected as before.
But now it doesn't ...
1
vote
1
answer
77
views
Get current function name
Executing
vscode.executeDocumentSymbolProvider
gives me all symbols in the file.
Can I somehow get name of the function that the cursor is currently in?
0
votes
1
answer
58
views
VSCode Failing to properly activate venvs in workspace with more than one folder/interpreter
Had an issue start with VSCode the last week or so, and not sure if there's just something wrong with my system, my vscode config, or if there's just a vscode bug.
To start, I'm running on OSx Sequoia ...
0
votes
0
answers
33
views
VSCode python (remote) - slow "rename symbol" when opening parent/root directories?
Given I have stored my git repos at ~/git/project1, ~/git/groupA/foo, etc.
When I open the root directory ~/git with VSCode and refactor code via "rename symbol" or "rename file",
...
-1
votes
1
answer
88
views
vscode extension uses wrong python
I am trying to use sqlfluff linter, which is a SQL formatter and linter. In settings.json I have, among others, this:
"[sql]": {
"editor.defaultFormatter": &...
1
vote
0
answers
34
views
Is there a way to have VS Code, dynamically, only process/include folders and files I have open and exclude the rest?
I have a big repo of python snippets. pyright goes crazy because I have a bunch of little folders with scripts.
I don't want to have a manually turn it on/off or open specific folders as projects. I ...
0
votes
0
answers
48
views
vscode debugger highlights wrong line when adding/removing previous lines
Let's assume we have this python script, set breakpoint on second line and start debugging:
print(1)
print(2) # set breakpoint here
print(3)
print(4)
print(5)
Debugger stops here:
Now delete the ...
0
votes
1
answer
592
views
How do you remove a python venv from vscode?
I've added several custom virtual environments to vscode, so that when I use the command palette I can select from a variety of builtin ones, as well as my own.
I'd like to remove some of these, but I ...
2
votes
1
answer
307
views
How to set Visual Studio Code Python Interpreter to a Python Virtual Environment in a Parent Directory?
I have a python virtual environment in /Documents and a project in /Documents/Code/Python/example. I want to use this venv in my project but I can't get the vs code python interpreter to recognize ...
1
vote
0
answers
82
views
Pylint protected-access (W0212) warning on module functions not class methods
I receive PylintW0212:protected-access warnings when accessing functions of a module that are prefixed with a single underscore:
import my_module
my_module._function() # Pylint warning here
The ...
1
vote
1
answer
229
views
$PYTHONSTARTUP points to an old version of the extension
Somehow I got myself into a state where python is complaining about PYTHONSTARTUP pointing to a non-existant path. From the terminal tab:
% python
Python 3.11.8 (v3.11.8:db85d51d3e, Feb 6 2024, 18:...
2
votes
1
answer
1k
views
How to input command line arguments when using pytest in VS Code
I have setup my pytest testing to use optional command line arguments. I would like to run and debug these tests in VS Code. However, I am unable to get the command line arguments to work with VS Code....
0
votes
0
answers
116
views
Why cls() in a classmethod does not provide argument hints the way that directly calling the class constructor does?
I'm trying to make a subclass with a @classmethod that would take as arguments an instance of its superclass and kwargs for its other fields. The goal is to be able to take an object of the general ...
0
votes
2
answers
1k
views
How to fix an issue of VS code terminal prompt adding an extra line to it after the program is executed
My VS Code is appending the miniconda3 path to the Power Shell prompt
every time I execute any code. This causes the PS prompt to be super long.
e.g.
PS C:\Users\name\Projects\Python Tutorials> **&...
1
vote
1
answer
642
views
Visual studio Code Python Intellisense not detecting return types
In past i always made functions that get a type/class as argument and create an instance of that type, returning the instance. E.g:
def CreateWidget(self, widgetType, show = True, name = '', x = 0,...
1
vote
3
answers
4k
views
how do I run only selected lines of my code in vs code
As I am following online course and working on python topics, there is a moment when I write
short lines of coding and than another coding all in the same page. Even though I separate them
with # ...
0
votes
1
answer
138
views
Support "View Value in Data Viewer" for custom class
In the VSCode Python debugger, I can right-click on numpy array or pandas DataFrame and select "View Value in Data Viewer". Is it possible to support this for a self-implemented class?
I ...
20
votes
10
answers
12k
views
VSCode does not update environment variables upon .env modification
I'm using .env in a Python project, with python-dotenv, but it seems like VSCode automatically loads the environment variables from the .env.
Unfortunately, VSCode does not seem to update the ...
-1
votes
1
answer
180
views
In VS Code, where are user settings saved and where to look for them? [duplicate]
In vscode, I am quite confused where to change settings and where to find them.
There seems at least two places: Settings and Command Palette.
For a specific example, I am using vscode for Python.
I ...
0
votes
1
answer
168
views
Installation error for PySCIPOpt in vscode Mac Ventura OS
I am working on a Mixed Interger Linear Programming problem. I wanted to use SCIP solver to find the optimised solution for my problem. I was trying to install "PySCIPOpt" package in vscode ...
0
votes
0
answers
76
views
VSCode Portable disable auto-expansion of folded blocks
In VSCode Portable, is there a method/setting to disable automatic expansion of folded functions (or other types of foldable blocks, I guess) on start-up? That is, if I fold a function block, close ...
-2
votes
1
answer
2k
views
Python for VS Code installation problem: "This extension is deprecated as it is no longer being maintained."
This extension is deprecated as it is no longer being maintained
Why is this message showing? Is it a problem? If so, how can fix it?
1
vote
0
answers
671
views
VSCode debuging flask app creates Error [WinError 10038] on save/reload [duplicate]
Since few days I have an issue with reloading when debugging flask apps. Usually, when saving changes the debugger restarts and I could work on my app.
Now it still saves and reloads, but throws an ...
0
votes
0
answers
932
views
VSCode not coloring certain Python modules
I have a Python virtual environment (venv) with several external libraries/packages installed, such as torch, gradio, and HuggingFace's transformers. I use the interpreter inside the venv to indicate ...
0
votes
1
answer
57
views
For loop iteration changing when I rerun the Python file
for i in range(1,5):
print(i)
a = input("Enter a Number")
If I don't Enter anything into the Input and Rerun the File again In VSCODE Terminal, The For loop iteration is advancing.
...
12
votes
1
answer
2k
views
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 ...
14
votes
1
answer
3k
views
Why are PyCharm and Pylance not detecting packages installed in editable mode?
Recently, code analysis tools like PyCharm and Pylance in VSCode are not picking up packages installed in editable mode (pip install -e <package_name>).
This made it so I could not navigate to ...
0
votes
1
answer
933
views
VSCode Python Extension: Autocomplete doesn't detect the type of an hinted attribute when it's used in the same method
When an attribute is created and hinted, and then used in the same method, the autocomplete doesn't work (only shows python object stuff):
But if I try to use the attribute inside another method, the ...
5
votes
3
answers
16k
views
VS Code issue when trying to install the Python extension: "end of central directory record signature not found"
When trying to install the Python extension I get the following error:
Error while installing 'Python' extension. Please check the [log](command:workbench.action.showWindowLog) for more details.
The ...
1
vote
2
answers
372
views
Vscode uses the other interpreter which is not the one that I selected
The python interpreter that I choose is python 3.7.16(tf:conda )which is set by anaconda. And its path in my computer is F:\anaconda\envs\tf\python.exe.
In the user's setting.json , I changed the ...
6
votes
1
answer
7k
views
VSCode Python Testing `Test result not found for...` bug
While working in a multi-project (VSCode would call it multi-root) python repository the VSCode python plugin for testing fails to run all the test when choosing to run all the tests, however running ...
1
vote
2
answers
2k
views
Kedro Pipeline contains no nodes after applying all provided filters
ValueError: Pipeline contains no nodes after applying all provided filters
src/pipelines/data_processing<br>
src/pipelines/data_science<br>
src/pipelines/data_project<br>
src/...
3
votes
0
answers
311
views
Debug tox unit tests with visual studio code
I am trying to debug an existing set of unit tests that are run with tox. I updated my launch.json file to include the following configuration:
{
"module": "tox",
"...
1
vote
3
answers
836
views
for-loop error : "Output exceeds the size limit." (VSCode)
I was trying to make a for loop to sum the integers from 1 to 100 in Python and wrote the code like this :
for i in range(1, 101) :
sum_list = []
sum_list.append(i)
print(sum(sum_list))
...
1
vote
0
answers
373
views
How to get list of parent methods in VSCode?
In PyCharm I can hit Ctrl/Cmd + O and it'll give me a modal with all methods I can override. What's the equivalent in VSCode?
4
votes
0
answers
381
views
VSCode python debugger isn't hitting breakpoint in a Notebook callback function
I'm running a(n) .ipynb file within VSCode, trying to debug a callback function. No breakpoints within the callback function are hit, although the breakpoint I've set in the main code cell correctly ...
10
votes
1
answer
5k
views
What's pylint's TypeVar name specification?
Pylint gives a warning whenever something like this happens:
import typing
SEQ_FR = typing.TypeVar("SEQ_FR")
#^^^^^ gets underlined with the warning
The warning is like this: Type variable ...
1
vote
1
answer
194
views
How to use a class attribute as the type hint for a method inside the class?
class Foo:
method_type: type
def method(self) -> ???:
# code
# Example use:
class FooStr(Foo):
method_type = str
foo_str = FooStr().method() # should be str according to ...
1
vote
1
answer
435
views
What is the alternative to python.pythonPath in settings.json?
In a Python tutorial I'm following, the Python path is linked to the python.pythonPath setting in the settings.json file of Visual Studio Code. However, the python.pythonPath does not exist anymore.
I ...
5
votes
2
answers
8k
views
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 ...
1
vote
1
answer
5k
views
vscode python: how to log to both file and terminal
Before adding logging to my project, i would see all logs from libraries such as flask in the terminal console. After adding the following, i no longer see these output in the terminal - but they do ...
4
votes
1
answer
2k
views
VSCode Import Quick Fixes always Relative to ${workspaceFolder}
I'm working on a python project within a pretty large multi-language mono-repo with VSCode's python tools (pylance). The root of the workspace(/repo) is not the root module of python imports.
When ...
6
votes
1
answer
4k
views
vscode/pylance auto-import incorrect root path
Let's suppose that I have a project with this file structure:
project_dir
└── src
├── package1
│ └── module1.py
└── package2
└── module2.py
When I want to use some class from ...
1
vote
0
answers
1k
views
devcontainer.json for VScode using existing Container
How to use existing container in VSCode?
I have a file called .devcontainer.json. The path is /home/myname/Documents/ABC/.devcontainer.
{
"name": "Kaggle Dev CPU",
"...
1
vote
0
answers
294
views
How to search python function definitions across all installed packages in vscode
I want to search for a function name across all installed packages and also in the packages defined by python.autoComplete.extraPaths vscode setting.
Vscode search panel searches only in the current ...
7
votes
0
answers
948
views
Linking VS Code interactive window to running Jupyter notebook
Let's say that you have two windows open in VS Code, one is a Jupyter notebook, and the other is the Python interactive window. Both are running the same kernel. Is there a way to link these two ...