PTVS hangs on run through without breakpoints

Jul 11, 2013 at 11:36 AM
Hi there,

First off PTVS looks absolutely AWESOME (just download the binary to give it a try after reading about it on big thanks to the team for their efforts!!

I have come across a strange issue though, but this may very well be because of my limited knowledge of the environment and may be compounded by limited knowledge of Python!

Whenever I try to run/debug a project from the VS2013 Preview (Django, console) it does nothing at all (it just hangs) UNLESS I put in a breakpoint somewhere at the start. This does seem to give it some time to warm up the engines (Python interpreter?) and start up the Django development server or display a Window through SDL etc.

Does anyone have any idea why this might be? (I am using Windows 7 & Python 2.7)

Many thanks,

Jul 12, 2013 at 10:57 PM
Thanks for the kind words, it's not immediately obvious why this might be happening, but hopefully we can figure it out and get it fixed. I have some questions to hopefully track down what's happening:

When you say "Django, console" are you using the Django management console to run? Or is this just a normal F5 launch w/ debugging?

Is VS unresponsive or is just nothing happening? Can you look in task manager and see if a python.exe process is created? And does Ctrl-F5 (launch w/o debugging) work?
Jul 14, 2013 at 12:02 PM
Thank you for your reply. Sorry for the lack of detail in my post, I have currently only created two projects and both display this behaviour, one is a standard Django project (from template), the other is a console project with a reference to the PySDL2 library and draws a simple Window to the screen. I have no access to my laptop atm but will post a detailed break down this week. Just off the top of my head it seemed like this behaviour was displayed using the Debug button but not when right clicking on .py file and choosing to run it from there but I will confirm this later (I will also check the task manager).
Jul 15, 2013 at 8:14 PM
I'm seeing the exact same issue. If I F5 a project with no breakpoints, the python.exe window opens empty and just sits there. After a few minutes, my web browser opens but can't connect to the server. If I insert a breakpoint, even on an empty line, everything works as expected.
Jul 15, 2013 at 9:07 PM
Ok, I suspect I know what this is now. Can you try waiting for a long time after the browser open and see if the site eventually comes up?

We had one issue reported which is a bug in another VS component fixed internally in VS 2013. The result is that launching debugging can be extremely slow to start, and it gets worse with the number of modules loaded in the app. Django loads a lot of modules, so it could be this issue.

We have a possible workaround for previous versions of VS but we've been trying to gauge how much of an issue this is in the real world. If Django eventually launches then it's probably this issue. I've seen it take 1 minute, and I've even seen it take multiple minutes to launch. If it does succeed and you can let us know how long it takes that'd be useful information as well.
Jul 20, 2013 at 8:44 PM
I have been experiencing the same issue, with no Django or web anywhere in the picture.
I just have a main python program that hangs when I start the debugging (F5), and I had to put a breakpoint in the start of the code to get things working.

Windows 7 Ultimate
Python 2.7.5
PTVS 2.0 beta
VS 2012 Professional
Jul 30, 2013 at 1:09 PM
Same here, but i found something...

I reduced my source code to:
import sys
import numpy
print('Hello World')

1)with F5 from visual studio this will hang with empty console window. (ill tried waiting for few minutes)
2)if i add breakpoint to line with "print('Hello World')", Debugger will stop at breakpoint in less than 1 second after F5
3)if i delete "import numpy" it will not hang, write the "hello world" to output and close the console window (as expected from code)

Windows 7 professional
Python 2.7
PTVS 2.0 beta
VS 2012 Premium

Python enviroment:
Python 2.7.5 64bit from
decorator (3.4.0)
distribute (0.6.45)
memoize (1.0.0)
numpy (1.7.1) from
pillow (2.1.0) from
pip (1.4)
Jul 30, 2013 at 11:47 PM
bgale & ttxman - the somewhat good news is that i recreated your environments & cannot repro your bug.
Jul 31, 2013 at 2:00 AM
OK. I downloaded the pdb symbols and enabled "native mode debugging". With "native mode debugging" it does not stuck...

Now it takes approximately 15 seconds after F5 until "hello world" is showed in the console window (python.exe).

Here is my debug output I don't like the lines with "exceptions.TypeError", can someone tell me if they are problem?

I will probably try clean install tomorrow.
Jul 31, 2013 at 5:03 AM
They are not the problem. Those are exceptions that are raised and caught by Python import machinery when importing modules (and, occasionally, by the modules themselves). For mixed-mode native/Python debugging, we don't have the concept of "caught" and "uncaught" exceptions yet - they are all treated as raised but potentially caught, so they never break by default. To avoid confusing people when an exception occurs, therefore, all exceptions are reported to the Output window at the point where they are raised.

This exception design is tentative and not necessarily final, so any feedback on what you would rather prefer to see is welcome.

The 15-second startup delay is also a known issue, and is actually also caused by the standard library, but in a different way - we have a somewhat expensive hook that fires whenever a new code object is created, which basically translates to every class and function definition, and there is a lot of those implicitly triggered even by a simple hello world. I'm looking into ways to speed this up.
Jul 31, 2013 at 9:55 AM
OK i will try something else... :)
Aug 1, 2013 at 9:45 PM
I can confirm that I have the same issue. Without a breakpoint anywhere in the code, the program would not execute and it just gets stuck. I have tried a clean install and also tried it on multiple versions (2012, 2013 etc) and machines. This was not an issue with the alpha release of 2.0 however. Please let me know what information i can provide to help diagnose the problem.
Aug 1, 2013 at 10:39 PM
Edited Aug 1, 2013 at 10:40 PM
I'd tried complete reinstall of python and PTVS it not helped. I also tried a different PC (windows 8 x64) and installed python for all users, then only for one user, didn't helped too.

The windows 7 one is after clean installation, so i can tell common software and settings.

Visual studio (2012 premium)
complete .NET SDKs (and help),
windows SDKs to get VC10 c++ compilers.
Opera browser
windows defender (win8 have integrated something like that)

system confing
disabled UAC
SSD as main disk
disabled hibernation
fixed swap to 1GB

Only thing i can think of is my Visual studio , it is from the MSDNAA so it can be slightly different (maybe)?
Aug 1, 2013 at 11:18 PM
arvmenon, do you have this problem on all your projects, or just for one particular project? If the latter, can you list the packages that you have imported there?

Also, can you try doing the same thing ttxman did for his repro - commenting out specific imports and seeing if that makes any difference. If this is something that has to do with specific packages, or something that only some packages have in common, we'd love to narrow down on them to get a better chance at reproducing the problem so that we can debug it.
Aug 2, 2013 at 12:12 AM
I uninstalled the 2.0 beta, and installed the 2.0 alpha. I can confirm, there is no stuck in the alpha build...
Aug 2, 2013 at 11:59 AM
pminaev, this happens with all of my projects.

My regular imports are

I can try commenting out specific imports and see what it does. Will report back.
Aug 7, 2013 at 12:45 AM

We think we have a fix for this issue. Can you please download these two files & try them before we call it good?

Aug 7, 2013 at 9:11 AM
Edited Aug 7, 2013 at 9:18 AM
OK i tried the files :) and YES it is fixed it for me..
Aug 15, 2013 at 9:38 PM
I verified that the files fixed the same problem in VS 2010. So you might call it good. Thanks!
Sep 5, 2013 at 9:41 AM
Verified with VS 2012 and VS 2013 for Windows 8. Thanks
Sep 10, 2013 at 9:43 PM
RC build is out and includes the fix.
Nov 8, 2014 at 9:09 PM
Ptools wrote:

We think we have a fix for this issue. Can you please download these two files & try them before we call it good?

I was reading through the various posts and I appear to have the same issue with my program hanging at start up.
Eventually it will run but it takes a excessively long time to get past the import statements.
I am running MS Visual Studio Express 2013 for Desktops with the PTVS 2.1 tool on Windows 7.
My program consists of the following two lines:

from pyalgotrade.barfeed import yahoofeed
print('Hello World')

In the post above there is reference to some files that fixed the issue. When I click the link the files are no longer available.
Please let me know if there is a solution to this issue that I can try and where I can find it.

Nov 8, 2014 at 11:18 PM
The fix is already in 2.1, so there's something else causing your issue.

Is pyalgotrade a public library? Where can I get a copy to test?
Nov 9, 2014 at 4:06 AM
Zooba wrote:
The fix is already in 2.1, so there's something else causing your issue.

Is pyalgotrade a public library? Where can I get a copy to test?
PyAlgoTrade can be found here.

Nov 13, 2014 at 6:18 PM
Thanks for that. I've had a chance to look today and it seems that importing that module will also import numpy, and numpy does quite a lot of expensive operations on import (such as compiling regexes). Depending on how the packages have been installed (.egg vs. folder) and your exception settings, this can take a long time to get through, and you should see a similarly long delay from just importing numpy.

Without knowing more about how your packages have been installed (a file listing of your site-packages folder would show me) and what exception settings you have selected, I can't suggest any workarounds other than disabling Just My Code (through Debug, Options menu), which will also disable breaking when exceptions are raised. We do hope to improve exception notifications at some point, which will probably help with this, but that will be in a later PTVS version.