importing scipy causes crashes when restarting app

When I run my app locally or deployed on pythonanywhere I recently starting experiencing crashes when I try to end the app (locally) or reload (pythonanywhere). Didn’t think much about it because things still roughly work but in pythonanywhere it turns a reload from 5 seconds to 30 seconds with segmentation fault errors and other weird behaviors. I traced it to when I started importing the scipy signal module. There are lots of posts about apache and mod_wsgi that suggest numpy/scipy cause issues with wsgi because they use C extension modules but it isn’t clear to me how to fix my app. I’m not using apache. Numpy seems to work fine. Anyone run into similar issues?

If you’re not using apache, how are you running this?

I know that compiled C extensions are very sensitive to version / compiler changes. You do want to ensure you’re using exactly the right (same) version of scipy as the version of Python being used. (As a managed host, I would expect PythonAnywhere to ensure that.)

I am not familiar with what is going on below django on pythonanywhere. I found an old post talking about switching from Apache to nginx+uWSGI but honestly have no idea what any of that means. I know I don’t have a configuration file as described Apache posts on this issue.

I control the versions of python and packages in my own virtual environment. I did have a mismatch on release dates. I updated the version of scipy. My problem seems to happen less often but still happens. I’ll play with this some more. Thanks for that tip.

Note: It’s not just release dates - it’s also specific versions and sub-versions. For example, if you’re running Python 3.9.2, then you need to be running a version of scipy that was compiled for Python 3.9.2. If you’re building scipy from source, then you need to ensure that your ‘-dev’ packages (or whatever your OS refers to the build libraries) correspond to the version of Python you’re running.