This is a Windows 11 machine. I have 2 projects in a Visual Studio 2022 solution.
- A Python CLI.
When I run this app, it opens thepython.exe
terminal.
- A C# Console app.
When I run this app, I think it openscmd.exe
terminal.
For the Python app also, I would like to run it in Windows cmd.exe terminal, so that I can use text formatters like colorama
or termcolor
.
The Environment is already set for cmd.exe, but it doesn't seem to work.
So, is it possible to run the Python CLI app, from VS 2022, in a Windows CMD terminal.
This is a Windows 11 machine. I have 2 projects in a Visual Studio 2022 solution.
- A Python CLI.
When I run this app, it opens thepython.exe
terminal.
- A C# Console app.
When I run this app, I think it openscmd.exe
terminal.
For the Python app also, I would like to run it in Windows cmd.exe terminal, so that I can use text formatters like colorama
or termcolor
.
The Environment is already set for cmd.exe, but it doesn't seem to work.
So, is it possible to run the Python CLI app, from VS 2022, in a Windows CMD terminal.
Share Improve this question edited Mar 24 at 16:02 President James K. Polk 42.1k29 gold badges109 silver badges145 bronze badges asked Mar 19 at 10:19 sukeshsukesh 2,41112 gold badges64 silver badges130 bronze badges 9- Visual Studio is likely running Python scripts using python.exe directly, which may prevent ANSI escape sequences (used by printy and colorama) from rendering correctly. This happens because python.exe does not enable ANSI support by default unless run inside a proper terminal like cmd.exe, PowerShell, or Windows Terminal. – user23633404 Commented Mar 19 at 10:45
- What do you see when you got to Options then Python then Interactive Window? Does it show CMD in the script text box? – user23633404 Commented Mar 19 at 12:13
- It has an option to select an Environment, and another for "Module". In the Environment, the current project's env is selected, and in the Module, "main" is preselected. There is no other place when I can select a terminal. – sukesh Commented Mar 19 at 12:27
- That box under Interactive Windows should be empty – user23633404 Commented Mar 19 at 12:42
- 1 Uninstalling and re installing the python development workload may work since the existing configuration that is using python.exe to run the code will be deleted, allowing for the new installation to create a configuration that may produce the results you intend to achieve. – user23633404 Commented Mar 20 at 5:01
1 Answer
Reset to default 01: Open the Integrated Terminal:
You can go to "View
" and select "Terminal
" to open an integrated terminal. Since your terminal setting already has cmd.exe
as the default shell, the terminal will use that.
2: Run your Python Script:
Inside the integrated terminal, you can navigate to your directory using cd
and run your Python file. python your_filename.py
This method will help you to run your Python Script inside
cmd.exe
, so that libraries likecolorama
ortermcolor
can format text effectively.