首页 > 解决方案 > Python:numpy:检测到解释器更改 - 每个进程只能将这个模块加载到一个解释器中

问题描述

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

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

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 的?

标签: pythonapachenumpyflaskwsgi

解决方案


尝试在 .conf 文件中添加WSGIApplicationGroup %{GLOBAL} 。(在我的情况下“纳米/etc/apache2/sites-available/FlaskApp.conf”)


推荐阅读