python - flask+uwsgi+nginx+centos 导入模块numpy报错
问题描述
带有numpy的virtualenv中的python 3.6
当我启动服务时:
r-python uwsgi[9729]: def empty_like(prototype, dtype=None, order=None, subok=None):
r-python uwsgi[9729]: File "/home/user01/python/conserva/conservaenv/lib64/python3.6/site-packages/numpy/core/overrides.py", line 240, in decorator
r-python uwsgi[9729]: docs_from_dispatcher=docs_from_dispatcher)(implementation)
r-python uwsgi[9729]: File "/home/user01/python/conserva/conservaenv/lib64/python3.6/site-packages/numpy/core/overrides.py", line 204, in decorator
r-python uwsgi[9729]: add_docstring(implementation, dispatcher.__doc__)
r-python uwsgi[9729]: RuntimeError: empty_like method already has a docstring
r-python uwsgi[9729]: VACUUM: unix socket conserva.sock removed.
r-python systemd[1]: conserva.service: main process exited, code=exited, status=22/n/a
r-python systemd[1]: Unit conserva.service entered failed state.
r-python systemd[1]: conserva.service failed.
如果我从应用程序代码中删除“import numpy”,服务就会运行。哪个是问题?我该如何解决?
解决方案
我在 uWSGI 下运行导入 numpy 的项目时遇到了这个问题。uWSGI 使用的默认子解释器和 numpy 的初始化之间存在一些交互。
你可以告诉 uWSGI 不要在你的 uWSGI 配置中使用子解释器:
single-interpreter = true
在哪里添加它取决于你如何配置 uWSGI。
推荐阅读
- spring-webflux - 如果 Flux 有异常,如何“窥视”?
- javascript - 如何从承诺中获取正常的 JSON 数据?
- spring-boot - 创建名为“scopedTarget.userPlatform”的 bean 时出错:范围“用户”对当前线程不活动
- r - 用 ggplot2 绘制向量,添加图例
- c# - 当列表确实包含对象时,IEnumerable 上的对象 Null 错误
- javascript - Node.js - 找到值后读取流,然后关闭
- jquery - 尝试使用自动完成时 JQuery 无法读取属性?
- python - 正则表达式字符串格式化
- java - JAX-RS 客户端是否调用已注册的 ContextResolver[s]?
- azure - Application Insights 中缺少故障异常智能警报