How do I suppress the console window when debugging python code in Python Tools for Visual Studio (PTVS)?

我怕爱的太早我们不能终老 提交于 2019-12-04 03:16:33

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.

Use the Python Interactive Window (CTRL-ALT-F8 or Debug Menu). You will have the code output on the python interactive shell (where you can obviously interact). The win terminal will not appear anymore.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!