IBM ILOG CPLEX and Python, Nightmare on a Mac!!

Lately, I was playing with CPLEX studio 12, and I found it a nightmare to set it up and running on a Mac OS X with Python. If you like to know how to get rid of the headache, then this topic is for you 🙂

Here is what we do:

1. Get the academic version by applying here:

2. Login to the account and  download CPLEX for Mac from here:

IBM Academic Initiative
More precisely, I had to search for CPLEX in catalog to find it:
IBM Academic Initiative Software Downloads

3. Download the academic license from here:

4. Install CPLEX binary by running the script from terminal.

5. Rename the license from access.ilm.rdp to access.ilm and copy it into the following folder (create the folder if it doesn’t exists):


NOTE: Make sure to rename it at this point, CPLEX won’t recognize the downloaded version of the file.

6. Now we can verify to see if CPLEX can run by going to its folder and run  ./cplex.

7. If we have the python installed in Mac (which is usually the case by default), then we can completely import CPLEX libraries and use it in a python program. To do that we go to the following folder:


now we need to run the following command to setup the libraries:

8. Once the libraries are setup, we need to add the path to the PYTHONPATH by running the following:

NOTE: you can add the above to your ~/.MacOSX/environment.plist to make it permanent.

9. Not done yet! since the CPLEX python only supports x86 architecture (even though CPLEX itself supports both x86 and x64), and Apple python by defaults run only in x64 mode in snow leopard, so we need to force python to run in x86 mode, and that can be done by:

10. Finally!!! That’s it, now we can run CPLEX code using python and enjoy.

Any question or comments is welcome.