简体   繁体   中英

Execute python file in a new terminal?

well, i'm trying to execute a python file in a new terminal. I've tried several thing, no result. I read this Execute terminal command from python in new terminal window? So i tried

subprocess.call(['gnome-terminal', '-x', 'python /root/Desktop/Script/website/bb.py'])

it opens me a new terminal but it says me "no such file or directory". i've tried differents paths without results.

What i'm doing wrong ?

Thanks i

it seems the warning because unproper path writing as you expected therefore you have to take care if these notes

  • path separator differs on operation system. Windows uses backslash \\ , Linux&Mac use slash /
  • in windows Desktop folder lies on C:\\\\Users\\[username]\\Desktop , on linux /home/[username]/Desktop
  • you can use os.path package to handle paths os.path.join

Tip drag the script file into your terminal to get the absolute path located on your file 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