Python: numpy: 检测到解释器更改 - 每个进程只能将此模块加载到一个解释器中

Python: numpy: Interpreter change detected - this module can only be loaded into one interpreter per process

我在 Ubuntu 18.04 上有一个 Flask 应用程序 运行,Apache 服务器,反应前端,Flask (selenium) 后端。

我的应用程序运行良好,但有时我会在多台服务器上收到以下消息:

numpy: Interpreter change detected - this module can only be loaded into one interpreter per process.

完整的错误日志:

mod_wsgi (pid=27625): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'.
[Tue Sep 15 05:01:05.669296 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300] Traceback (most recent call last):
[Tue Sep 15 05:01:05.669407 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300]   File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>
[Tue Sep 15 05:01:05.669451 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300]     from FlaskApp import app as application
[Tue Sep 15 05:01:05.669497 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300]   File "/var/www/FlaskApp/FlaskApp/__init__.py", line 5, in <module>
[Tue Sep 15 05:01:05.669538 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300]     import pandas as pd
[Tue Sep 15 05:01:05.669585 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300]   File "/usr/local/lib/python3.6/dist-packages/pandas/__init__.py", line 17, in <module>
[Tue Sep 15 05:01:05.669624 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300]     "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
[Tue Sep 15 05:01:05.669677 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300] ImportError: Unable to import required dependencies:
[Tue Sep 15 05:01:05.669718 2020] [wsgi:error] [pid 27625:tid 140687123134208] [client 209.17.96.82:41300] numpy: Interpreter change detected - this module can only be loaded into one interpreter per process.

我不知道发生了什么或我应该改变什么。我读了一些关于更新 ini 文件以使用单一解释器的内容。

single-interpreter = true

但是我不确定这是否适用于我的应用程序,因为我使用的是 wsgi 而这是针对 uswgi 的?

尝试在您的 .conf 文件中添加 WSGIApplicationGroup %{GLOBAL}。 (在我的例子中是“nano /etc/apache2/sites-available/FlaskApp.conf”)