First, install a working copy of Python, plus the numpy library. One method to install Python is to install a pre-configured installation such as Anaconda. For example, if you download anaconda, then from a shell you should be able to execute:

conda create --name py310 python=3.10
conda activate py310
conda install numpy

The next step is to configure your system so that IDL and Python can find each other.

Windows


In your Python script (or in the interactive Python console), include the following commands to use the Python-to-IDL Bridge:

import sys
sys.path.append('<IDL_DIR>/lib/bridges')
from idlpy import *

where <IDL_DIR> should be replaced with your IDL installation directory. If you have ENVI installed, then this lib/bridges directory will be inside the IDL subdirectory.

Tip: To avoid having to do the sys.path.append in each script, you can add the <IDL_DIR>/lib/bridges directory to your system PYTHONPATH environment variable.

Linux


In your Python script (or in the interactive Python console), include the following commands to use the Python-to-IDL Bridge:

import sys
sys.path.append('<IDL_DIR>/lib/bridges')
from idlpy import *

where <IDL_DIR> should be replaced with your IDL installation directory. If you have ENVI installed, then this lib/bridges directory will be inside the IDL subdirectory.

Tip: To avoid having to do the sys.path.append in each script, you can add the <IDL_DIR>/lib/bridges directory to your system PYTHONPATH environment variable.

macOS


In your Python script (or in the interactive Python console), include the following commands to use the Python-to-IDL Bridge:

import sys
sys.path.append('<IDL_DIR>/lib/bridges')
from idlpy import *

where <IDL_DIR> should be replaced with your IDL installation directory. If you have ENVI installed, then this lib/bridges directory will be inside the IDL subdirectory.

Tip: To avoid having to do the sys.path.append in each script, you can add the <IDL_DIR>/lib/bridges directory to your system PYTHONPATH environment variable.

Testing Your Installation


Once you have loaded IDL using the above Python statements, you should be able to execute IDL commands:

>>> IDL.print("hello, world!")
hello, world!
>>> p = IDL.plot(test=1)

If you receive any errors, make sure that Python is able to find the idlpy.py script, either by doing the sys.path.append or using the PYTHONPATH environment variable.

Note: On Linux or macOS, if you receive any errors about INTEL MKL, this is due to a conflict between IDL's mkl library and Python's mkl. To resolve the problem, issue the following commands from a terminal:

conda uninstall mkl
conda install nomkl
conda install numpy

See Also


IDL to Python Bridge Installation, Using the Python to IDL Bridge