0

I am working on a python script to analyze astronomy images and I am trying to open a DS9 window within a python script (DS9 is a utility that allows images to be interactively viewed and analyzed). Usually I would open DS9 by going into the Linux terminal and typing:

>ds9 &

and then it would pop up in another window.

I tried to mimic this in my python script by writing the following line:

os.system('ds9 &')

When I would run the script the DS9 window would pop up but the rest of the script would not run until I closed the DS9 window. This gave me errors because the tasks that followed needed a DS9 window to be opened.

I am wondering if there is a way to open a window from within a python scripts and still have the rest of the script continue running.

Perhaps:

os.system('ds9 &')

isn't the right approach?

4

1 回答 1

1

您可以使用subprocess模块。
subprocess是一种产生进程的新方法,而不是使用os.spawn*()or os.system()

在你的情况下:

import subprocess
subprocess.Popen(["ds9"])

这应该在后台运行ds9

请参阅此处的文档。

于 2013-06-14T04:38:42.000 回答