简体   繁体   中英

how can I write code of terminal inside python script at windows

How can I send this code below as a command from python script to be run on tirminal:

cd %HOMEPATH%

conda install git

git clone https://github.com/facebookresearch/demucs

cd demucs

conda env update -f environment-cpu.yml

conda activate demucs

python.exe -m demucs.separate -d cpu --dl "PATH_TO_AUDIO_FILE_1" ["PATH_TO_AUDIO_FILE_2"...]

I applied this code:

import os
os.system("cd %HOMEPATH%")
os.system("conda install git")
os.system("git clone https://github.com/facebookresearch/demucs")
os.system("cd demucs")
os.system("conda env update -f environment-cpu.yml")
os.system("conda activate demucs")
os.system("python.exe -m demucs.separate -d cpu --dl 'C:/Users/Arwa_Analyst/Downloads/CAPSTONE PROJECT/research samples/audioDataset/Eval_S_Wav/-1hDIl9Udkw.wav' ")

and I got this errors:

enter image description here

enter image description here

import os

os.system("cd %HOMEPATH%")
os.system("conda install git")
#...
#..

You can use the import os package and use system function to run terminal commands from python.

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