Search code examples
pythoncplexdocplex

How to connect your installed academic initiative of CPLEx with python?


I am using python 3.6 version and CPLEX 12.10 in MAC with Anaconda. How do I access the cplex libraries for python? I have an academic version installed in my MAC and can be used independently in GUI.


Solution

  • What do you want to use ? There are the CPLEX python api which is a python API to the matrix interface of CPLEX - And there is docplex, which is the object oriented modeling layer based on CPLEX.

    In anycase, if running a solve showed the error of promotional version, then it means that somehow you installed the cplex package in the past.

    Before you start, please open a Terminal console and make sure it is setup to use your installation of Anaconda, and that your conda environment is activated (if you use one).

    First you want to install whatever cplex was installed using conda uninstall cplex if you installed using conda or pip uninstall cplex if you were using pip.

    Then you have a choice. Either you add $CPLEX_STUDIO_DIR1210/cplex/python/3.6/x86-64_osx to your PYTHONPATH or you install the CPLEX python wrappers:

    $ cd $CPLEX_STUDIO_DIR1210/cplex/python/3.6/x86-64_osx
    $ python setup.py install