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

Sun*_*ios 4 python apache wsgi numpy flask

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

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

numpy: Interpreter change detected - this module can only be loaded into one interpreter per process.
Run Code Online (Sandbox Code Playgroud)

完整的错误日志:

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.

Run Code Online (Sandbox Code Playgroud)

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

single-interpreter = true
Run Code Online (Sandbox Code Playgroud)

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

ram*_*uez 10

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