221

How to configure the IDL Python bridge on recent Linux flavor such as Ubuntu 20

 

Some recent Linux flavors - such as Ubuntu 20- are not shipped with a /usr/bin/python link. They are shipped with a /usr/bin/python3 link instead. However, our current IDL-Python bridge, as of at least IDL 8.8.0, requires a python command to run.

In addition, more recent Linux flavors may have missing libraries required for the IDL-Python bridge, such as pip, numpy or distutils.

 

How to identify the issue related to the missing “python” command?

When launching the IDL to Python bridge it fails with the below error:

 IDL> >>> import sys
% PYTHON::LOAD:  is not a supported python version.
% Execution halted at: $MAIN$  

If your Python version is supported, this error may be due to the lack of a valid "python" command on your path. Indeed, IDL is looking specifically for a “python command to initialize the IDL-Python bridge, and not to a python3 command. 

 

How to fix the error related to the lack of “python” command?

The easiest way to fix this error is to create a symbolic link from python to python3 in /usr/bin:

$ sudo ln -s /usr/bin/python3 /usr/bin/python

Then try again to run bridge from IDL 8.8.

 

How to identify the issue related to missing distutils library?

When launching the IDL to Python bridge it fails with an error such as:

 ModuleNotFoundError: No module named 'distutils.util'

 

How to fix the error related to missing distutils library?

You will need to install the package including the distutils library:

$ sudo apt update

sudo apt-get install python3-distutils

 

How to identify the issue related to missing numpy library?

When launching the IDL to Python bridge it fails with an error such as:

% PYTHON::LOAD: numpy is not installed for this python distribution and is required for the IDL-python bridge.

 

How to fix the error related to missing numpy library?

 

a. Ubuntu 20.04 does not include pip. First step will then consist in installing pip:

$ sudo apt update

$ sudo apt install python3-pip

 

b. Then install numpy

$ /usr/bin/python -m pip install numpy

 

How to test the IDL bridge is fully working?

 

a. Run the python bridge setup script:

$ sudo python setup.py install

Installing the IDL Python bridge.

Python-to-IDL library location:

    /usr/local/harris/idl88/bin/bin.linux.x86_64/pythonidl38.so

IDL-to-Python library location:

    /usr/local/harris/idl88/bin/bin.linux.x86_64/idl_python38.so

Creating idl_python.pth file containing the IDL Python bridge paths

running install

running build

running install_data

copying /tmp/idl_python.pth -> /usr/lib/python3/dist-packages

running install_egg_info

Writing /usr/local/lib/python3.8/dist-packages/idl_python-2.0.egg-info

Removing temporary idl_python.pth file

Setup is complete.

 

b. Run IDL->Python bridge

IDL> >>>import sys

% Loaded DLM: PYTHON38.

IDL> >>>print(sys.version)

3.8.5 (default, Jul 28 2020, 12:59:40)

[GCC 9.3.0]

 

c. Run Python->IDL bridge

$ python

Python 3.8.5 (default, Jul 28 2020, 12:59:40)

[GCC 9.3.0] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>> from idlpy import *

IDL 8.8.0 (linux x86_64 m64).

(c) 2020, Harris Geospatial Solutions, Inc.

Licensed for use by: xxxxxxx.

License: MNT-xxxxxx

>>> IDL.sqrt(4)

2.0

 

 

 

-----------------------

written by BC on 12/17/2020 - reviewed by BC (US) on 12/17/2020

Please login or register to post comments.