I have php-fpm running as nginx user in a docker container. Dockerfile creates correct anaconda environment called 'ss' with pandas package. It works ok when I attach to the docker container.
Docker CMD runs an init.sh script:
. /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;'
Then, a PHP script runs Python script using
shell_exec("python ss.py");
This errors with:
ImportError: No module named pandas
I tried various combinations of shell_exec where I tried activating the env before running the script, but it mostly errors out with:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'
How do I activate the 'ss' env for all PHP shell_exec scripts?
you can directly use like this.
shell_exec('/root/.conda/envs/my-rdkit-env/bin/python3 ss.py');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.