'Apache error log -- how to fix "numpy ImportError" or disable it?

I'm running a Django app on Apache with mod_wsgi -- everything seems to be working but the following error has been clogging up my logs, running every 30 mins or so:

ImportError: Unable to import required dependencies:
[wsgi:error] [pid 8715] numpy: Interpreter change detected - this module can only be loaded into one interpreter per process.

From what I've read, this is due to numpy not playing well with sub-interpreters, but I haven't found a good solution yet as to how I can fix this in the mod_wsgi configuration. I'm not using numpy in any of the stuff I'm serving to the web, but it's still a required module for my python project on the back end. Don't have too much experience on this side, but I'm guessing apache is trying to import the modules that I've set in my requirements.txt and running into this error?



Solution 1:[1]

  • numpy does not allow the interpreter (execution environment) to change
  • wsgi has a mechanism to separate interpreters for different virtual hosts

To support this, add this description to the place where WSGIScriptAlias etc. are written, so that the interpreter will not be modified.

WSGIApplicationGroup %{GLOBAL}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 yoshitaka okada