Python connection to SAOimage DS9 via XPA
Switch branches/tags
Nothing to show
Clone or download
Latest commit c1bf67a Jul 23, 2018

Python connection to ds9 via XPA

Build Status

The XPA messaging system provides seamless communication between many kinds of Unix programs, including Tcl/Tk programs such as ds9. The pyds9 module uses a Python interface to XPA to communicate with ds9. It supports communication with all of ds9's XPA access points.

The easiest way to install pyds9 is:

pip install --upgrade [--user] pyds9

To install the development version from ericmandel/pyds9, the following command can be used.

> pip install [--user] git+

WARNING: due to some interaction between astropy_helper and sphinx, the command might fail with a RecursioError if sphinx>=1.6 is present.

Alternatively, you can clone the git repository or download and unpack the zip file. Then cd into the pyds9 directory and issue:

> python [--user] install

If the compilation of the C files in xpa directory fails saying that doesn't find the header file X11/Intrinsic.h make sure to install the relevant packages:

  • openSUSE: sudo zypper install libXt-devel
  • Ubuntu: sudo apt-get install libxt-dev

To run:

# start up python
> python
    ... (startup messages) ...
>>> import pyds9
>>> print(pyds9.ds9_targets())
>>> d = pyds9.DS9()  # will open a new ds9 window or connect to an existing one
>>> d.set("file /path/to/fits")  # send the file to the open ds9 session

If you create a test.fits file and a casa.fits file in the working directory you can test basic ds9 functionalities running the function:

> pyds9.test()

The install will build and install both the XPA shared library and the xpans name server. By default, the code generated for the shared object will match the address size of the host machine, i.e. 32-bit or 64-bit as the case may be. But on 64-bit Intel machines, the XPA build also will check whether python itself is 64-bit. If not, will add the "-m32" switch to the compile options to build a 32-bit shared object. This check can be overridden by defining the CFLAGS environment variable (which can be anything sensible, including an empty string).

For Linux, the X Window System libraries and header files must be available. On some versions of Linux (e.g., debian), the development libraries must be installed explicitly. If you have problems, please let us know.

To report a bug, ask for a new feature, or request support, please contact us at

Eric Mandel and Francesco Montesano