Console windows closes right after I hit ctrl+F5 in visual studio tools for python

北慕城南 提交于 2019-12-21 11:26:23

问题


I have installed Python Tools for Visual Studio and I cannot see the output in the console window like I see output when I run a C# console application within visual studio upon hitting the following Shortcut keys.

F5 -- Starts debugging the program and closes the console window in c# and in Python
Ctrl+F5 -- Start without debugging, works as expected in C# but not in Python program. It always exits the console window under both the options.

There is a third option "Execute Project in Python Interactive" for a Python Application. This option sometimes produces output and sometimes does not.

What should I do to see the output in the console window and the windows should not close after running the program? Is this even possible or some conceptual difference for python console apps?

Am I doing something wrong here?


回答1:


There's an option in Tools->Options->Python Tools->Advanced under the Debugging section for "Wait for input when process exits abnormally" and "Wait for input when the process exits normally". I thought they were supposed to be on by default but enabling them should cause it to wait.




回答2:


for future visitors from google. This doesn't involve Python settings, but to prevent the console window from closing automatically while using "Start without debugging" (Ctrl + F5). Try looking for this setting.

Project -> "project name" Properties -> Configuration Properties -> Linker -> System
Then look for the SubSystem property, and set it to Console (/SUBSYSTEM:CONSOLE) You can select it via drop down or try and type it. if you have trouble seeing it under System you can also check under All Options

Hit save and then it should work immediately. Confirmed this works on VisualStudio 2013, but I also think it works on other versions too.




回答3:


UPDATE: Visual Studio 2017 - the items listed have moved :-( and I don't know where they moved to



来源:https://stackoverflow.com/questions/9424873/console-windows-closes-right-after-i-hit-ctrlf5-in-visual-studio-tools-for-pyth

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