gpt4 book ai didi

php - [Linux, Ubuntu] : Executing a Python script with different users results in different behaviours

转载 作者:IT王子 更新时间:2023-10-29 00:44:26 26 4
gpt4 key购买 nike

我正在尝试使用我的用户“ubuntu”在 Ubuntu 中使用 Python 执行脚本。它是亚马逊的虚拟机,所以我正在尝试执行该代码

$execQuery = "python script.py";
exec($execQuery, $output, $return);

通过使用 ubuntu 执行该命令,结果是 OK,但是从 PHP(用户是 www-data)执行它,我得到:

ImportError: No module named skimage.io

所以我认为权限有误,但由于我从未使用过 Python,所以我不知道我必须在哪里设置正确的权限。

有人知道吗?

非常感谢。


我试过使用 pip install ___ --user www-data 但也没有用。

最佳答案

好吧,这很奇怪,虽然它在主用户上运行,但在 www-data 上却没有运行。

问题显然出在 sckit-image Python 模块中,我认为这是一个权限问题。事实上,www-data 用户没有找到正确的库,即使我设置了 $PYTHONPATH 并且你也尝试从脚本中导入它:

import sys
sys.path.insert(0, "path/to/python");

但什么也没发生。

安装 scikit-image 时。 scipy 出错,同时给我 gfortran 一个错误。

sudo apt-get install gfortran 并重新安装 scipyscikit-image 解决了问题。

关于php - [Linux, Ubuntu] : Executing a Python script with different users results in different behaviours,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30778823/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com