4833
Using the IDL-Python Bridge on Mac
The purpose of this help article is to have a collection of the different versions of Python that have been tested on Mac. This article also lists the environment variables that have been set to get different versions of Python to work or a comment mentioning that the IDL-Python bridge does not work.The basic environment variables that have been set can be found here:
http://www.exelisvis.com/docs/Python.html
NOTE: You may need to change the paths in the environment variables depending upon where you installed Python and IDL. Additionally, not all variations of Python may work with IDL. This is because Python is open source and there is a chance that each Python package is built differently and there may be other built in differences for each distribution that cause incompatibilities with IDL. These examples are meant as a general guideline to get the IDL-Python bridge to work and it may require some troubleshooting before it successfully works.
Also note that these instances of the IDL-Python bridge were set up using the bash shell in the Apple terminal. The default location that these variables need to be added is .bash_profile. If you want to use the c-shell you can place similar variables in the ~/.cshrc file. The environment variables will need to be changed for using the c-shell and you cannot copy/paste these into your .cshrc file and expect them to work.
Anaconda with Python 2.7
The IDL-Python bridge successfully works with Anaconda using Python 2.7. The environment variables that are set in ~/.bash_profile are:
export PATH="/Users/tech_support/anaconda/bin:$PATH"
DYLD_LIBRARY_PATH="/System/Library/Frameworks/ImageIO.framework/Resources"
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/lib"
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Users/tech_support/anaconda/lib"
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Applications/exelis/idl85/bin/bin.darwin.x86_64"
export DYLD_LIBRARY_PATH
export PYTHONHOME="/Users/tech_support/anaconda"
PYTHONPATH="/Applications/exelis/idl85/bin/bin.darwin.x86_64"
PYTHONPATH="$PYTHONPATH:/Applications/exelis/idl85/lib/bridges"
export PYTHONPATH
source /Applications/exelis/idl85/bin/idl_setup.bash
Update:
Recent versions of MacOS (such as 10.12 and 10.13) include System Integrity Protection which prevents the DYLD_LIBRARY_PATH from being set. Therefore, a setup.py script was added in IDL 8.6.1 to setup the environment to run within a SIP enabled environment. To use the IDL-Python Bridge with Anaconda (with Python 2.7) in a SIP environment, use the procedure below:
1) Set the PATH, PYTHONHOME, and PYTHONPATH environment variables as shown in steps above.
2) You need to setup the system so that the environment variable PYTHONHOME will be inherited by a "sudo" call. To do this,open a terminal and type the command, "sudo visudo". Inside this file, add the following line:
Defaults env_keep += "PYTHONHOME"
3) Run the "setup.py" script using the following command:
cd /Applications/Harris/IDL87/lib/bridges
sudo python setup.py install
Enthought Canopy
The IDL_Python bridge for Enthought Canopy
does not currently work, but here are the environment variables that were set in ~/.bash_profile to test this:
export PATH="/Users/tech_support/enthought_canopy/User/bin:$PATH"
DYLD_LIBRARY_PATH="/System/Library/Frameworks/ImageIO.framework/Resources"
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/lib"
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Users/tech_support/enthought_canopy/User/lib"
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/Applications/exelis/idl85/bin/bin.darwin.x86_64"
export DYLD_LIBRARY_PATH
#export PYTHONHOME="/Users/tech_support/enthought_canopy"
PYTHONPATH="/Applications/exelis/idl85/bin/bin.darwin.x86_64"
PYTHONPATH="$PYTHONPATH:/Applications/exelis/idl85/lib/bridges"
export PYTHONPATH
source /Applications/exelis/idl85/bin/idl_setup.bash
Reviewed by DS 11/7/2016; Updated by DS 8/9/2018