Spyder kernel restarted after running pystan.StanModel(model_code=...)

Hi, I am new to stan and I am using a Mac OS Catalina 10.15.5 and Spyder 3.3.6 and python 3.7.0.

I have found that whenever I have a bug in my model_code, my Spyder kernel will restart without showing any info. This has been a nightmare to debug.

It actually worked on a linux server for me, I think it might be related to my gcc setup? So here is my gcc info:
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.59)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Before I run the code  pystan.StanModel(model_code=...)

And after I run the code pystan.StanModel(model_code=…) and I know it contains some error, I have my kernel all cleaned up


Not sure why I can’t attach a picture, trying it again

@ahartikainen is the go-to Python person, but he has been quite busy lately…

Anyway, the problem might be that with PyStan the model AFAIK runs tightly coupled with the python process and this can result in all sorts of trouble. You may want to check if using CmdStanPy instead resolves the problem.

Thanks for the reply. I am wondering if this issue has been reported to stan before? My local python environment seems to be working well for all the other things I did.

Or is it a mac related issue? As the problem disappears when I connect to a remote linux server.

Hi, we have had problems with Spyder earlier. Not sure why that happens. Can you try to add verbose=True to see if there are some C++ errors?

Probably spyder tweaks some cython(?) setting which causes segfault when C++ exception is raised. (This is just my guess)

1 Like

Hi just tried to add verbose = True in pystan.StanModel(). The issue remains the same. I couldn’t find any info through either the spyder kernel or the terminal.

I just found that when I do python3 …py through terminal I could get a useful error message.