Having Issues with Python debugging in vscode - python

I am pretty new to all this so bare with me, I am confused on what is going on with my setup to debug my python code. I have the most current updates for vscode, and the latest python 3 (3.8.5 64-bit). However when I try to start a debug, I get an time out error along with "Command 'cmd' not found, but there are 16 similar ones." Any ideas on how to fix this?

Try to reset your default terminal with the following steps:
press Ctrl+Shift+` to open a new terminal;
click the drop-down menu and choose Select Default Shell:
select Command Prompt:
Then reload window to make the setting work. You can try this to see if the problem goes away.

Related

VScode : Everytime I press Run python File in Terminal button, run in powershell always

Everytime I run python file at vscode(in this case I press Run python File in Terminal button), terminal is opened as Powershell always.
my select default profile settings are command prompt. so when I open a new terminal, it opens with cmd. However, when I run the python file even though the cmd terminal is open, a new powershell terminal is launched. and I don't know why...
How do i fix it ?
Yeah, it's an issue of VSCode In version v1.60.0. You can refer to GitHub issue #132150 for more details.
There are a lot of people report this kind of problem recently.
And the only workaround to this problem is to roll back the version to v1.59 until the release of v1.60.1 for now.
There might be an issue in your select default profile settings. However, you can always choose a default shell by pressing ctrl + ~ (~ tilda key) You can open up a shell in vscode, as seen below. By default this might open up powershell, from there you can select your default shell.
Note: Some of the options seen in the image require WSL2 (Windows Subsystem for Linux) to be installed and activated on any Windows system. Clicking any of those options will open a new tab of that shell, but if you click on the '+' plus button or restart vscode later, it will go back to the default shell (powershell) in our case.
Now click the option on the bottom that says select default profile
And you should see a window like this:
From there you can select the default shell in this window. And these changes will be saved, so anytime you click the '+' plus button to open a new shell instance, or relaunch vscode it will open your selected shell choice by default.
And that's it! From here you can select cmd since you want that to be your default shell. And you should be good to go. You can change these settings at anytime, by following these steps again.
Since you're using Python. I suggest using powershell for one reason. You can use a tool known as chocolatey which is like a package manager for windows that can download, install/update, and most importantly set environment variable paths in windows automatically. Which might be a lot easier than doing it manually on cmd.
To run the python script you can do the following:
$ python /path/to/file.py
If you want to run your python file in the terminal with cmd then you just open a new terminal and type the command
python "path/to/file.py"
If it doesn't work try using
py "path/to/file.py"

Python Extension is not working in vscode bc of & command

I installed python then configured it for vscode by following docs of vscode, but they said I have to right-click on the editor after seeing a run Python in terminal. And I have to click on it.
But it only works in Powershell and when I tried to use it in cmd, then they said ----
D:\Program\Applications\C++>& D:/Compilers-Interpreters/Python38-32/python.exe d:/Program/Applications/C++/app.py
& was unexpected at this time.
D:\Program\Applications\C++>
I am using the C++ folder bc I was also trying to set up C++ by following the tutorial in vscode doc. Now can someone tell me how to fix this & problem????
This is a problem with VSCode, On the VSCode insiders it has been solved. You can wait for the next stable release of VSCode.
You can take this as a workaround for now:
Take adventage of terminal.integrated.shell.windows instead of terminal.integrated.defaultProfile.windows for now.
You can refer to here for more details.
It seems that for some reason & is being added to the beginning of your command, which makes the command invalid.
Upon testing, I actually am running into the same issue, suggesting it could be an issue with VS Code and Python. I would recommend using the debugger to run your program, which still seems to work. Just press F5 and select Python File: Debug the currently active Python file. Another way to do this is to define the launch.json configuration to automatically launch upon pressing F5.

Pycharm Python Console Won't Run Anything from Script

I am unable to get my pycharm console to access anything from my script. Likewise, when I tell a single line of code to execute in the console, an an error like the one shown in the image is thrown. I am sure that something is not configured correctly, and would appreciate any assistance.
You have a generic console open that doesn't have your script loaded into in automatically. You can tell because the name of the console is "Python Console".
Right click on the code editor window, then at the bottom, click "Run file in Python Console". That will create a new console with the script loaded.
I made that into a key combination (in the Key Bindings in settings) because it's such a common task for me.
You don't need a python console. Just right click on the script name and select run or in pycharm terminal : python script.py
It depends on your scrip

Terminal shows only an empty non-editable cursor in VS Code

Something has changed in my VS code that doesn't allow me to type in my Terminal. I'm sure it's a config issue but not sure where to look. This is what I see:
I tried changing my Python version or shell showing on the terminal but no luck. How can I fix this?
I had the same problem when learning some PHP. After clicking on every option modifier available, I found that in the bottom Status Bar, there was a "Normal" view on the left.
Right-clicked, and selected "Hide Normal" and the cursor and my ability to write code came backImage of my VSCode showing VIM cursor
In the end I found that I had the VIM extension enabled and had not used its variables correctly. Either uninstall the extension or use its commands

Lost My "Output" Window

I am sure I am using incorrect terminology, but hopefully you can grasp my meaning. I am working with Spyder python 2.7, and I have somehow lost my "output" window. I attached a screen shot. Formerly, there was a window, that, after having run my code, gave me the results of my code. How do I get this window back? I went to the view options, but had no such luck.
(Spyder dev here) You have two options to make your console back (that's the right name of what you called as output window :)
Go to the View Menu and there from to Windows and toolbars and select either Console or IPython console.
If this doesn't solve your problem, just open a Windows terminal (i.e. cmd.exe from the Start > Run Window menu) and in it run this comnmand:
spyder --reset
and then restart Spyder again. That should solve your problem for sure.

Categories

Resources