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

后端 未结 2 2066
礼貌的吻别
礼貌的吻别 2021-02-20 07:29

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 acce

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 07:45

    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.

    Windows Application Checkbox

    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.

提交回复
热议问题