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

4
  • stackoverflow.com/questions/42729130/… Already answered here Commented Sep 10, 2021 at 9:06
  • 1
    Does this answer your question? Visual Studio Code, how to switch from powershell.exe to cmd.exe Commented Sep 10, 2021 at 9: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 Commented Sep 10, 2021 at 9:37
  • Please post text instead of images - see How to Ask. Commented Sep 10, 2021 at 13:41

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much for clearing up my confusion! I already thought I was turning crazy
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.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.