Issue with Visual Studio Code and debugging Python - python

I am currently running on Ubuntu 20.04 with the 1.45.1 version of Visual Studio Code. I am using the Microsoft Python extension.
VS Code: 1.45.1
Python Extension 2020.5.78807
Code Runner 0.10.0
Python: 3.8.2
Pip: 20.2
I have set break points in code and activate debugging (F5). However I am unable to debug the application (again using F5). I can run using Code Runner (right click Run Code) and it successfully run but break points are never hit.
I have found no solution or workaround other than using another IDE. I am used to running in VS Code and would prefer to not have to switch IDE/editor. Any help would be appreciated.
I can debug in PyCharm or IDLE, just not VS Code.

Related

I wonder why python with homebrew doensn't work in VScode

I have installed python3 with homebrew, but it keeps making errors when i run.
i think problem is that i'm not working at homebrew file, so i've searched but couldn't get solutions.
which python3
give me
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3
and i'm using Python 3.9.9 64-bit interpreter in /opt/homebrew/bin/python3
How can i make my VScode work with homebrew python3enter image description here?
If you focus on the terminal you can probably press arrow up to see which command Visual Studio code used to run your program. It'll probably reveal the path of the python interpreter.
I used the answer from https://stackoverflow.com/a/51488832/467650 to make Visual Studio Code run with the desired python interpreter (which also for me was the homebrew one:
I pressed ⇧⌘P, found Python: Select Interpreter and entered the full path of the python executable. After that Visual Studio Code run just fine.

visual studio code (run Python file in terminal does not work)

visual studio code, pressing run does not work on mac. Let say I want to print the word "Hello" and run the code print("Hello"), it will not be executed. I tried reinstalling python and visual studio but I could't resolve the problem.
When this happens to me, the Python interpreter borked and I need to press ctrl + c (abort) in the terminal a couple of times. It's still in the Python process and vscode is trying to input the run command into a Python process that's not actually a terminal.
I ran into the same issue. Figured out that I forgot to select the Add Python 3.8 to PATH while installing. You can either choose to uninstall and reinstall Python and make sure to select the above option OR you can manually update the user environment variable for PATH and add the path to scripts and python like the following.
C:\Users\<addyourusernamehere>\AppData\Local\Programs\Python\Python38-32\Scripts\
C:\Users\<addyourusernamehere>\AppData\Local\Programs\Python\Python38-32\
For me, downgrading VS Code extension called Python helped.
This shows where the option to install another version is in VS Code Extensions
As for today, I had to go back to version 2021.11.1422169775
M1 MacBook, macOS Monterey 12.2.1

Is there any way to use the python IDLE Shell in visual studio code?

I was programming python in Visual Studio Code and every time that I ran something it would use the integrated terminal (logically, because I have not changed any settings) and I was wondering, how could I get it to use the Python IDLE's shell instead of the integrated terminal (which for me is useless)?
I have also got Python IDLE installed in my mac but due to Visual Studio Code having "intellisense", it is way easier.
In VS Code you should be able to select the file which is supposed to be used in the terminal.
Under :
Preferences -> Settings -> Terminal

Visual Studio Code set up for Python

I have installed VS core under Windows 7. When I try to run a really simple python script, it gives the attached error.
Any suggestions?

Microsoft Visual Studio 2015 Interactive window

I'm running Microsoft Visual Studio 2015 and trying to run Python 3.4 - 64-bit but the interactive window shows <disconnected>. If I try to restart it - I get the following error:
Method Not found:'Microsoft.VisualStudio.Text.SpanMicrosoft.VisualStudio.InteractiveWindow.IInteractiveWindow.WriteErro(System.String)'.
I've tried to reinstall the updated and appropriate python tool kit. I've even repaired my installation of visual studio. The interactive window is nonfunctional and I can't type anything into the window. This is true if I change the interpreter to 2.7. Configure interactive window properties doesn't have any options that will connect it to the python interpreter.
Python Debug Interactive also doesn't work and gives the same error.
Right click > Highlighting code > send to interactive, in a .py file that is open (which runs fine) also gives same error.
I believe this is because you need to install a separate interpreter (CPython, IronPython), as described here: https://github.com/Microsoft/PTVS/wiki/PTVS-Installation

Categories