Fix PyCharm: Python quit unexpectedly

Rodrigo Silveira
Dec 3, 2019 · 2 min read
Why is PyCharm suddenly unable to run Python scripts?

I’m a long time user of JetBrains IDEs. Simply the best. My Python workflow includes running scripts using PyCharm’s built-in Run/Debug configuration. If you don’t take advantage of this feature, I invite you to do so next time you’re writing code.

The Problem

The other day I got the error message above:

Python quit unexpectedly.Process:               Python [8520]
Path: /Library/Frameworks/Python.framework/Versions/3.6/Resources/
Identifier: Python
Version: 3.6.8 (3.6.8)
Code Type: X86-64 (Native)
Parent Process: pycharm [4412]
Responsible: Python [8520]
User ID: 501
Date/Time: 2019-12-02 22:05:05.623 -0700
OS Version: Mac OS X 10.14.6 (18G1012)
Report Version: 12
Bridge OS Version: 4.1 (17P1081)
Anonymous UUID: 8D27C45B-6035-3C83-450A-8A74DCA59153
Time Awake Since Boot: 1100 secondsSystem Integrity Protection: enabledCrashed Thread: 0 Dispatch queue: Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
dyld2 mode
abort() called
Thread 0 Crashed:: Dispatch queue:
0 libsystem_kernel.dylib 0x00007fff624922c6 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff6254dbf1 pthread_kill + 284
2 libsystem_c.dylib 0x00007fff623fc6a6 abort + 127
3 org.python.python 0x000000010664cb84 Py_FatalError + 484
4 org.python.python 0x000000010664c95c _Py_InitializeEx_Private + 1372
5 org.python.python 0x0000000106669540 Py_Main + 2064
6 org.python.python 0x0000000106545df8 0x106545000 + 3576
7 libdyld.dylib 0x00007fff623573d5 start + 1
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x0000000000000000 rbx: 0x00000001074bb5c0 rcx: 0x00007ffee96ba368 rdx: 0x0000000000000000
rdi: 0x0000000000000307 rsi: 0x0000000000000006 rbp: 0x00007ffee96ba3a0 rsp: 0x00007ffee96ba368
r8: 0x0000000106572a80 r9: 0x0000000000000000 r10: 0x0000000000000000 r11: 0x0000000000000206
r12: 0x0000000000000307 r13: 0x00007fa9f0065ef8 r14: 0x0000000000000006 r15: 0x000000000000002d
rip: 0x00007fff624922c6 rfl: 0x0000000000000206 cr2: 0x00007fff98bec188

Logical CPU: 0
Error Code: 0x02000148
Trap Number: 133

Closing and reopening the IDE didn’t help. Rebooting the laptop didn’t help. I thought about taking out the MacOSX cartridge, blowing on it, and trying again, but couldn’t find the reset button.

The Cause

As it turns out, one of the last things I did some time before the problem started happening was something I do often: when I want to run a very one-off piece of Python, I create a throwaway script, type in my one-off code, and run it:

# Using PyCharm's built-in terminal

In this case, I already had a file named and (my two go-to throwaway script names), so I did this:


And that is precisely the source of the above IDE crash, believe it or not.

The Solution

As it turns out, is a module in the standard library used by several other modules. When I tried running my “real” scripts, my version of was loaded by other modules trying to use the real .

The solution: in my case, I just deleted the throwaway file. If I really wanted it, I could have just renamed it to something else, but you get the point now.

Rodrigo Silveira

Written by

Software engineer fascinated with learning, practicing, and teaching.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade