如何在phpfpm shell\u exec中激活anaconda环境?

2024-05-28 22:52:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我在docker容器中以nginx用户的身份运行php-fpm。 Dockerfile使用pandas包创建正确的名为“ss”的anaconda环境。当我连接到docker容器时,它工作正常。你知道吗

Docker CMD运行初始化.sh脚本:

. /opt/conda/etc/profile.d/conda.sh
conda activate /opt/conda/envs/ss
php-fpm --fpm-config /etc/php-fpm.conf
nginx -g 'daemon off;'

然后,PHP脚本使用

shell_exec("python ss.py");

此错误包括:

ImportError: No module named pandas

我尝试了shell_exec的各种组合,在运行脚本之前,我尝试激活env,但主要错误是:

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'

如何为所有PHP shell\u exec脚本激活“ss”env?你知道吗


Tags: docker脚本pandasshetcnginxshellconda

热门问题