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
0
votes
0 answers

remote vscode python extension, connot import installed package

As is shown in the following picture, whenever I enable the python extension in my remote linux server, there will be a 'cannnot import' problem. I use conda in my remote server, and torch is already installed in my virtual environment. I've looked…
Arist12
  • 172
  • 1
  • 7
0
votes
1 answer

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 show up in the log file. I would like to have…
mike01010
  • 5,226
  • 6
  • 44
  • 77
0
votes
0 answers

VSCode Pytest - Python Test Explorer is able to find test but doesn't run them with correct path

My VSCode is able to find all my tests and lets my run them from the explorer, but upon running them it is calling the wrong path. I'm using a Poetry virtual environment which is in a different path than the tests. From the Python Test Adapter…
user19448827
  • 69
  • 1
  • 3
0
votes
1 answer

Pylance can't resolve the import of a library under same package

I am using VSCode and Pylance. I have the following workspace - src - company - __init__.py - team - __init__.py - project - __init__.py - A.py - B.py And I have some libraries that I import in A.py…
0
votes
1 answer

VSCode: How to fix Python extension version for Python 2 compatibility and prevent automatic upgrade?

I have a legacy code using Python 2. The last version of VSCode Python extension that supports Python 2 is v2022.2.1924087327 It is very easy to change the extension to an older version. My problem is that VSCode always automatically updates the…
neves
  • 33,186
  • 27
  • 159
  • 192
0
votes
1 answer

generate visual studio code's like .pyi file

.pyi file in visual studio code (python extension) in my case _csv.pyi file has more details on type hints compared to the .pyi file generated by mypy stubgen for example, in the code below you can see both .pyi file visual studio code…
SinaMobasheri
  • 729
  • 8
  • 17
0
votes
2 answers

VS Code issue with interpreter selector not showing (Python with image)

I have had it working previously but not sure what I did to remove it or delete it possibly. I can't see the python environment selector anymore in VS Code for Python, I am almost certain it is the source for many other issues I am experiencing. I…
0
votes
1 answer

python.defaultInterpreterPath in VS Code's settings.json shows "unknown configuration setting"

The old python.pythonPath has been deprecated in the latest vscode 1.64.1 and replaced by python.defaultInterpreterPath. However, when I set it in projectname/.vscode/settings.json, it is greyed and shown a popup as: unknown configuration…
derek
  • 9,358
  • 11
  • 53
  • 94
0
votes
0 answers

Running Python code in VSCode - how to make the output more readable?

I write Python scripts using Visual Studio Code. When I run a script using CodeRunner, the output is nicely spaced and separated from output of previous runs, like this: But, when I use the Python extension, the script runs in the terminal and…
Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
0
votes
2 answers

Using Python environments in VS Code outside of python files

The Python vscode extension allows us to select venv as well as python interpreters. I seems like the Python extension is only started when opening a .py file. So before that, it is not possible to use it to switch env. I would like to create a…
B3th4
  • 113
  • 1
  • 2
  • 10
0
votes
2 answers

Pandas Data Frame, reading from a file or setting a new Data Frame inside a function

I am trying to read 3 CSV files into 3 pandas DataFrame. But after executing the function the variable seems not available. Tries to create a blank data frame outside the function and read and set the frame in the function. But the frame is blank. #…
0
votes
0 answers

VSCode: how to configure my project to automatically activate Python extension?

To activate Python extension in VSCode I must open a Python file. Can I activate it without opening a Python file? I saw this issue, but couldn't see if there is a configuration in my workspace settings to do it. If I open a python file the…
neves
  • 33,186
  • 27
  • 159
  • 192
0
votes
0 answers

'Kernel died with exit code 1' Error with Jupyter Notebook in VS Code

I am trying to run a Jupyter notebook in VS Code but I keep getting this error code: I have Python 3.8.8 which was installed using Anaconda. The project folder has a virtual environment created using venv. I tried the solutions given here but none…
Chirag Bhansali
  • 1,900
  • 1
  • 15
  • 22
0
votes
1 answer

Separate .env for testing vs debug

I'm utilizing VSCode devcontainers, and I'm having difficulty trying to figure out how to run a different .env file for my pytest setup, versus when I just want to run uvicorn/debug. I can set an envfile in settings.json, which works, but I'd have…
Nate Dellinger
  • 740
  • 5
  • 14
0
votes
1 answer

Call Stack empty when debugging Python

I am working in a multithreading project in Python using VSCode and the Python extension. Everything was working right until suddenly, without me changing any setting) it stopped showing the running processes and threads in the Call Stack. The Call…
Tiago
  • 347
  • 1
  • 3
  • 12
1 2 3
8 9