1

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 ?

s9e5on
  • 11
  • 1
  • 4
  • 1
    It sounds like another manifestation of a known bug in v1.60.0, expected to be fixed in v1.60.1 soon - see [this answer](https://stackoverflow.com/a/69050730/45375). – mklement0 Sep 08 '21 at 04:20

3 Answers3

5

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.

Steven-MSFT
  • 7,438
  • 1
  • 5
  • 13
0

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.

The arrow key next to the plus button will show you all the other shell options

Some of the options seen in the image require WSL2 to be installed and activated on the windows system

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.

enter image description here

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.

enter image description here

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
-1

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"
Lalan Kumar
  • 107
  • 6