The Python Bridge consists of two components: the IDL to Python bridge and the Python to IDL bridge. The bridge provides the following features:

  • Compatible with multiple versions of Python (see IDL System Requirements for details)
  • Provides access to all IDL routines and Python modules
  • Seamlessly looks like an IDL object or Python module
  • All bridge output is redirected to the standard output
  • Automatic handling of case sensitivity and row/column major
  • Can execute arbitrary command strings in either language
  • Automatic data conversion from IDL arrays to numpy arrays
  • Data is passed by reference when calling routines/methods
  • Can pass main variables back and forth

The Python Bridge also has a kernel for running IDL in an IPython notebook. See IDL IPython Notebook Kernel for details.


Use Python commands in the following ways to convert a 10 x 2 matrix representing Cartesian coordinates to Polar coordinates.

Example 1, IDL to Python Objects


IDL> np = Python.Import('numpy')
IDL> coords = np.random.random([10,2])
IDL> x = coords[0,*]
IDL> y = coords[1,*]
IDL> r = np.sqrt(x^2+y^2)
IDL> t = np.arctan2(y,x)
IDL> print, r
IDL> print, t

Example 2, IDL to Python Command Line Mode

In IDL you can directly enter Python "command-line mode" by typing three ">>>" characters and pressing the Enter key:

IDL> >>>
>>> import numpy as np
>>> coords = np.random.random((10,2))
>>> x,y = coords[:,0], coords[:,1]
>>> r = np.sqrt(x**2+y**2)
>>> t = np.arctan2(y,x)
>>> print(r)
>>> print(t)

At the end, press the Enter key to re-enter the normal IDL command mode.

Example 3, Python to IDL

In Python, you can easily access all IDL functionality:

>>> from idlpy import *
>>> import numpy as np
>>> coords = np.random.random((10,2))
>>> x,y = coords[:,0], coords[:,1]
>>> r = IDL.sqrt(x**2+y**2)
>>> t = IDL.atan(y,x)
>>> print(r)
>>> print(t)

Version History




Added support for Python 3.5, added setup.py script


Added support for Python 3.6

8.7.1 Removed Python 3.4 support.
8.8 Added support for Python 3.7 and 3.8. Removed support for Python 2.7 and 3.5.
8.8.1 Added support for Python 3.9
8.8.2 Added support for Python 3.10. Removed support for Python 3.6.
8.9 Removed support for Python 3.7; simplified installation for all platforms.
9.0 Added support for Python 3.11.