doujia8801 2018-06-05 21:19
浏览 61

来自php的python调用中的MemoryError

I'm getting an annoying error without an apparent reason.

Here's the setup: I have a python script (Python 3.6 anaconda distribution) which is being called from Php (7.2.6) all on CentOS 7.

The PHP to Python call is via exec, and looks like this

exec("LANG='en_US.UTF8' " . "/opt/anaconda3/bin/python". " /home/my_web_user_name/public_html/my_python_script.py " . $parameters);

All works as a charm, if I call the PhP file (with the exec in it) from a terminal, simply as

php the_phpFile.php

However, when the same file is being called from the browser (the website user) I get the following error (the short version)

"/opt/anaconda3/lib/python3.6/ctypes/__init__.py", 
line 273, in _reset_cache CFUNCTYPE(c_int)(lambda: None) MemoryError

and this is the full history of calls before the error occurs.

Traceback (most recent call last): File 
"/home/my_web_user_name/public_html/my_python_script.py", line 8, in from 
nltk.stem import PorterStemmer File "/opt/anaconda3/lib/python3.6/site- 
packages/nltk/__init__.py", 

line 114, in from nltk.collocations import * File 
"/opt/anaconda3/lib/python3.6/site-packages/nltk/collocations.py", 
line 39, in from nltk.metrics import ContingencyMeasures, 
BigramAssocMeasures, TrigramAssocMeasures File 
"/opt/anaconda3/lib/python3.6/site-packages/nltk/metrics/__init__.py", 
line 16, in from nltk.metrics.scores import (accuracy, precision, recall, 
f_measure, File "/opt/anaconda3/lib/python3.6/site- 
packages/nltk/metrics/scores.py", line 18, in from scipy.stats.stats import 
betai File "/opt/anaconda3/lib/python3.6/site-packages/scipy/__init__.py", 

line 61, in from numpy import show_config as show_numpy_config File 
"/opt/anaconda3/lib/python3.6/site-packages/numpy/__init__.py", 
line 142, in from . import add_newdocs File 
"/opt/anaconda3/lib/python3.6/site-packages/numpy/add_newdocs.py", 
line 13, in from numpy.lib import add_newdoc File 
"/opt/anaconda3/lib/python3.6/site-packages/numpy/lib/__init__.py", 
line 8, in from .type_check import * File 
"/opt/anaconda3/lib/python3.6/site-packages/numpy/lib/type_check.py", 
line 11, in import numpy.core.numeric as _nx File 
"/opt/anaconda3/lib/python3.6/site-packages/numpy/core/__init__.py", 
line 35, in from . import _internal # for freeze programs File 
"/opt/anaconda3/lib/python3.6/site-packages/numpy/core/_internal.py", 
line 15, in import ctypes File 
"/opt/anaconda3/lib/python3.6/ctypes/__init__.py", 
line 538, in _reset_cache() File 
"/opt/anaconda3/lib/python3.6/ctypes/__init__.py", 
line 273, in _reset_cache CFUNCTYPE(c_int)(lambda: None) MemoryError

It seems clear that the error comes as a result of a call to nltk module, and indeed, if I turn it off the error disappears. On the other hand, things work fine when called from the terminal. So I think this has to do with some permissions.

In any case, I have no clue why this is happening.

Any ideas on this would be much appreciated.

  • 写回答

1条回答 默认 最新

  • doumu5934 2019-05-25 06:55
    关注

    Seems like the solution is disable SeLinux and reboot machine. Cause even by setting correct properties with "semanage" it wouldn't work.

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置