4

I would like to run my Python files and projects in the integrated cmd terminal of VS Code (I am using version 1.60.0) in combination with my Anaconda environment.

For this purpose, I already set the Anaconda environment as the default Python interpreter and changed the default profile in the global user settings of VS Code to use cmd terminals by default. If I click on 'New Terminal' (the plus button in the integrated terminal section) it works as expected and my Anaconda environment is automatically activated in a new cmd terminal. However, everytime I use the 'Run Python File' or 'Debug Python File' buttons, VS Code opens up a new PowerShell terminal and tries to run the Python file there.

I can find no way of changing this behaviour to use the cmd terminal instead. Any help is greatly appreciated! Many thanks in advance.

EDIT: To clarify the desired behaviour that I would like to achieve: I would like to be able to press the "Run Python file in terminal" button and have the file being executed in the cmd line automatically. Instead VS Code opens a new PowerShell and tries to run the Python file there.

EDIT 2: As pointed out in the linked pages I tried setting the terminal.integrated.shell.windows setting. However, VS Code tells me that this setting is deprecated. Following the instruction about how to update the settings I changed the settings to the new nomenclature, which did not solve my issue either.

settings.json file

diamon
  • 69
  • 5
  • https://stackoverflow.com/questions/42729130/visual-studio-code-how-to-switch-from-powershell-exe-to-cmd-exe Already answered here – Metapod Sep 10 '21 at 09:06
  • 1
    Does this answer your question? [Visual Studio Code, how to switch from powershell.exe to cmd.exe](https://stackoverflow.com/questions/42729130/visual-studio-code-how-to-switch-from-powershell-exe-to-cmd-exe) – AcK Sep 10 '21 at 09:09
  • Thanks for your answers, however, as explained above, I already set cmd as the default terminal, just as pointed out by the articles that you linked. Opening a new terminal complies with the setting and starts a cmd window. However, clicking on "Run Python file in terminal" does not comply with the setting and tries to run the file in a PowerShell – diamon Sep 10 '21 at 09:37
  • Please post text instead of images - see [ask]. – AcK Sep 10 '21 at 13:41

2 Answers2

4

This is a bug in v1.60.0 and it will be fixed in next release.

See bug report: Python extension does not honor default terminal type

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22
  • If my answer solves your confusion, it's appreciated that you [accept](https://stackoverflow.com/help/someone-answers) it to mark the question as resolved. – Molly Wang-MSFT Sep 10 '21 at 09:50
  • 1
    Thank you so much for clearing up my confusion! I already thought I was turning crazy – diamon Sep 10 '21 at 10:56
0
  1. You can run cmd and locate your python file where is it. and you can also type file location in cmd

  2. you can open cmd in that folder where your python file is located and type "cmd" in address bar of your folder and now you can locate your python file.

  • Thanks for your answer! I am aware that I can execute the Python files by using the cmd terminal. However, in order to optimise the workflow I would like to be able to press the "Run Python file in terminal" button and have the file being executed in the cmd line automatically. What happens instead is that VS Code tries to open a new PowerShell and execute the file there – diamon Sep 10 '21 at 09:02