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


Ensure that your Python executable is on the system PATH environment variable. IDL will use the first Python executable that it finds. If you use a virtual environment such as Anaconda from a Windows shell, then the correct Python should automatically be on your path after you activate it. If you are using your own Python installation then you may need to add Python to your system path. Here are some possible scenarios:

IDL Command Line or Workbench

You will need to add the Python executable to your Windows system PATH environment variable.

Anaconda Prompt or Git Bash with IDL Command Line

Once you do the conda activate command, you should not need to modify the PATH. IDL should automatically find the correct Python.

Windows Powershell with IDL Command Line

You will need to add the Python executable to your Windows system PATH environment variable.

Linux


Ensure that your Python executable is on the system PATH environment variable. IDL will use the first Python executable that it finds. If you use a virtual environment such as Anaconda, then the correct Python should automatically be on your path after you activate it. If you are using your own Python installation then you may need to add Python to your system path.

In addition, you will need to add the Python lib directory to the LD_LIBRARY_PATH environment variable.

For example, if you are using Anaconda, then you should be able to execute:

conda activate py310
setenv LD_LIBRARY_PATH ${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}
idl
IDL> >>>2+2

macOS


Ensure that your Python executable is on the system PATH environment variable. IDL will use the first Python executable that it finds. If you use a virtual environment such as Anaconda, then the correct Python should automatically be on your path after you activate it. If you are using your own Python installation then you may need to add Python to your system path.

On macOS, the final step is to run the setup.py install script for the IDL Python bridge. Using the Mac terminal shell, navigate to the <IDL_DIR>/lib/bridges directory and then run the script.

For example:

cd /Applications/<install dir>/idlxx/lib/bridges
python setup.py

This script will install a symbolic link in your IDL bin directory that points to the correct Python library.

Note: Be sure that you run setup.py using the same Python that you wish to use for the IDL Python bridge.

Note: Depending on the installation location and who installed IDL, you might need to run the setup.py script as a "super-user" (sudo). If the script fails with an error about permissions, either re-run the script using these elevated privileges or contact your System Administrator and have them run the script.

Testing Your Installation


Once you have completed the installation, you should be able to start IDL and execute Python commands:

IDL> >>>2+2
% Loaded DLM: PYTHON310.
4

If you receive any errors, make sure that the correct Python is on your system PATH.

On Linux, if you receive an error about loading the library, make sure that the Python lib directory has been added to LD_LIBRARY_PATH.

On macOS, if you receive an error about loading the library, make sure that you have run the setup.py script using the correct Python.

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


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