Why are Python scripts quitting unexpectedly on Windows 10?


I have a Windows 10 PC which has recently developed the following interesting problem. I write a lot of Python code and long-running scripts have recently started quitting for, as far as I can tell, no reason.

As an example, I can start my Django-based webpage with python manage.py runserver and it will occasionally load in the browser, but as soon as I try to do anything with it, the script will stop without any kind of exit code or error message. This same script was running fine until recently and I do not know what might have changed.

It might be related to the number of programs I have running - they tend to die more quickly when multiple windows are open - but as the CPU usage and memory are consistently under 50% utilised, I can't imagine why this would be a problem.

I've tried running my code in debug mode, but as the code struggles to start and as this affects multiple scripts using multiple packages, often with no overlap of imports or code, I'm rather at a loss with what to try next. It only seems to affect Python-related scripts, although most of my work is Python. I'm leaning towards this being a Windows issue rather than a Python one given that the same code is running fine on other systems.

I'm using Python 3.7.0 on Windows 10.

Example display from Django code:

(venv) C:\Users\User\mydjangocode>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
January 05, 2020 - 11:54:02
Django version 3.0.2, using settings 'mycode.settings'
Starting development server at
Quit the server with CTRL-BREAK.

(venv) C:\Users\User\mydjangocode>

There was around a five minute period after the line Quit the server with CTRL-BREAK. was displayed before I tried to visit The script quit almost instantly as soon as I tried to load the page.


I've tried changing to a non-venv version of Python, with no effect.

I've checked Windows Event Viewer and there are a lot of recent error messages in there.

Faulting application name: python.exe, version:, time stamp: 0x5b331a30
Faulting module name: python37.dll, version:, time stamp: 0x5b3319ec
Exception code: 0xc0000005
Fault offset: 0x000000000002a8fb
Faulting process ID: 0x4e0c
Faulting application start time: 0x01d5c3c171203e29
Faulting application path: C:\Program Files\Python37\python.exe
Faulting module path: C:\Program Files\Python37\python37.dll
Report ID: 164a49d4-38e6-41e9-9cfa-3fa2b0a99bed
Faulting package full name: 
Faulting package-relative application ID: 

I've also tried upgrading to Python 3.8 with no effect.


I've run the system file check utility which didn't highlight any issues:

C:\WINDOWS\system32>sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection did not find any integrity violations.

I've also run CHKDSK which hasn't highlighted anything.

asked on Stack Overflow Jan 5, 2020 by SqrtPi • edited Jan 5, 2020 by SqrtPi

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0