I am using Terminal to run code on my macOS High Sierra. I use Python all the time on my laptop (all day every day) and this is the first time I have seen this and it's come somewhat suddenly. I haven't used any new libraries that I don't usually use.

The Error

The error is a pop-up when I run code after importing it from another file that says:

Python has quite unexpectedly Click Reopen to open the application again. Click Report to see more detailed information and send a report to Apple.

Attempts to Fix

I've tried uninstalling a re-installing Python (https://stackoverflow.com/questions/40732280/python-quit-unexpectedly-on-mac) using the following commands:

brew uninstall --ignore-dependencies --force python python@2 unset PYTHONPATH brew install python python@2


brew uninstall --ignore-dependencies --force python python@3 unset PYTHONPATH brew install python python@3

This doesn't help. I've also quit all processes and restarted them. This also doesn't work.

The only thing I can think of that I've done today that I've never done before is create the ability to open a .xps file in my Google drive.

Where the Error is Coming From

I have a long class called preprocess_in_batches.PreprocessForTopicModelling which has an attribute called preprocess. If I do the following in preprocess_in_batches.py it works fine:

if __name__ == "__main__": preprocess = PreprocessForTopicModelling(gpu=False) preprocess.preprocess(...)

However, if I do it from another Python file, then I get this weird quitting of Python:

from preprocess_in_batches import PreprocessForTopicModelling def test_preprocess_in_batches(): preprocess = PreprocessForTopicModelling(gpu=False) preprocess.preprocess(...) if __name__ == "__main__": test_preprocess_in_batches()

I just don't understand why Python is quitting. Firstly I can't see anything illegal that I'm doing with my code. And even if there is a simple bug I'm missing, why is it quitting instead of throwing up an error?

  • Since you have both python2 and python3 on your machine are you using virtual environments? – jmh Aug 1 '18 at 13:54
  • How are you running python as that looks like a gui crash. – user151019 Aug 1 '18 at 17:41
  • Did you ever figure this out? I have exactly the same issue – rainkinz Jan 10 at 20:50

You must log in to answer this question.

Browse other questions tagged .