简体   繁体   中英

java call python in virtualenv

how to use java to call python in virtualenv? this is my .sh file

#!/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

when i use it in terminal,it runs but failed in java

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

how can java change the environment of conda? like use source activate xxx???

i solve this question by set python to /home/cery/anaconda3/bin/python. i guess this is caused by the environment conflict with conda and system

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