简体   繁体   中英

python(anaconda) from exec() of php

I try to call python from exec() of php on apache server.

I use anaconda for my environment.

<?php
$cmd = "conda activate myenv;python xxx.py";
exec($cmd,$output);
var_dump($output);

It shows

array(0) { }

but conda activate myenv;python xxx.py works in console and show json.

How should I solve this?

You are running 2 commands:

conda activate myenv
python xxx.py

This means that $output will be an array. Try to use var_dump($output) to see the result.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM