java在virtualen中调用python

2024-10-02 18:26:16 发布

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

如何在virtualenv中使用java调用python? 这是我的.sh文件

#!/bin/bash

source activate pytorch41&&
cd /home/cery/workspace/pytorch-CycleGAN-and-pix2pix&&
python test.py --dataroot datasets/vangogh2photo/SHU --name style_vangogh_pretrained --model test --no_dropout

当我在终端中使用它时,它运行了,但在java中失败了

String[] args = new String[] {"bash","/home/cery/workspace/pytorch-CycleGAN-and-pix2pix/photo.sh"};
        Process proc = Runtime.getRuntime().exec(args);

java如何改变conda的环境?比如使用源代码激活xxx???你知道吗


Tags: and文件testbashhomestringvirtualenvsh