简体   繁体   中英

Run $Path command in Terminal in a python script

i use ipython notebook and I want to call a terminal command: fft <in> <out>

my "fft" is in my $PATH so using a terminal, this would work.

How can I run this command in my ipython notebook?


the problem is that my fft executable is in my $PATH folder, and python won't recognize this

Found the solution:

import os    
os.system("xterm -e 'bash -c \"fft -i 3 AddedK AddedK_ifft; exit -f exec bash\"' ")

xterm opens a new terminal

fft ...; calls the function fft

exit -f closes the terminal

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