In PTVS the default behavior is for the program to print to the Python console window and the Visual Studio Debug Output window.
Realizing that it won't be able to accept user input, how do I suppress the Python console window?
Python in Visual Studio supports debugging without a project. With a stand-alone Python file open, right-click in the editor, select Start with Debugging, and Visual Studio launches the script with the global default environment (see Python environments) and no arguments.
Go to your project properties, either by right-clicking on the project and picking "Properties" or by picking Properties from the Project menu. Click on Debug, then enter your arguments into the "Script Arguments" field. Save.
From the Command Palette (Ctrl+Shift+P), select the Python: Start REPL command to open a REPL terminal for the currently selected Python interpreter. In the REPL, you can then enter and run lines of code one at a time.
This was more difficult to figure out than expected, but as usual, simple once you know.
The quick answer.
In the Solution Explorer, right click on the project and select Properties. On the General tab check the box next to Windows Application.
Then save and close the properties window. Done!
Other details from the discussion of an issue posted in 2012 on the PTVS codeplex site.
Python shell appears in addition to output window of IDE
The typical way to hide the Python console window is to set the Windows Application property (in the project properties window), which will then run pythonw.exe instead of python.exe. This is only really an option if you don't provide any input while your program is running - the output window in VS is not a console and does not support typing into your program. Also, this option is per-project, so you'll have to set it for each project. (It also seems to not be working in our latest builds, so we'll fix that asap...)
The other option is to stop printing output in Visual Studio and only use the console window. If you are suffering performance issues, this is more likely to solve the problem. To do this, open Tools->Options->Python Tools->Advanced and deselect "Tee program output to Debug Output window". You will probably also want to select "Wait for input when process exits normally" while you are here. Now all output will go to the Python console (you can right-click the title bar and choose Properties to make it bigger), which will be faster.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With