简体   繁体   中英

Edit: Subprocess wont open python file in new window?

I have this python file in the same folder as the one being executed. And I'm trying to execute the file in a new terminal window (I'm using Linux) using subprocess. The new window opens, but its giving me the error Failed to execute child process "/usr/bin/python3 /media/root/MYDRIVE/tools/sniff/sniffer.py" (No such file or directory) . Could anyone explain?

import subprocess
current_path = os.path.dirname(os.path.realpath(__file__))
subprocess.call(['gnome-terminal', '-x', '/usr/bin/python3 '+ current_path+'/sniffer.py'])

Try the following

import os
os.system("gnome-terminal -e 'bash -c \"python3 sniffer.py\"'")

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