Python calls cplex_DOcplex-how to successfully install and call the academic version of DOcplex

created at 08-18-2021 views: 29


This article describes how to properly install and configure the academic version of docplex


  • python 3.7
  • pycharm 
  • cplex studio 12.9 (download address of IBM official website). The academic version is recommended.


1 Install the academic version of Cplex Studio.
Because docplex needs to call the cplex solver, you need to install Cplex Studio in advance before installing the docplex installation package. The academic version of Cplex Studio 12.9 is used here. Run the installer and follow the instructions step by step. If you are not at ease, you can google graphic tutorials yourself (in fact, the same).

2 Copy the cplex folder to the python folder
From the installation directory of cplex, for example, my path is: C:\Program Files\IBM\ILOG\CPLEX_Studio129\cplex\python\3.7\x64_win64, find the cplex/ folder

Copy the cplex folder to the site-packages subfolder under the Lib folder in the python 3.7 installation directory. For example, my path is: C:\Users\lemur\AppData\Local\Programs\Python\Python37\Lib\site-packages

At this point, you can directly call cplex in python, just like using pip.


It is not possible to directly use the pip install cplex command in the pycharm terminal to install it. This installs the non-academic version (which can only solve small-scale problems, and if the variable is less than two thousand, it prompts an error: CPLEX Error 1016 ).

Step 2 has copied the cplex folder and can be used directly, so there is no need to install cplex again here.

It is said that after copying, even uninstalling cplex studio does not affect python calls, but I have not tried it.

3. Install docplex

In the pycharm terminal, use the command pip install docplex to install the docplex package in the python interpreter used by the current project.

At this point, the installation is complete.

When using it, you only need to introduce the corresponding library of docplex into the code.


It is best to use the local python 3.7 interpreter here, instead of using the virtual interpreter of the project. The reasons are as follows:

The configuration may be different

If the virtual interpreter is installed in the current project, docplex needs to be reinstalled when other projects are called. Because other projects use their own virtual interpreter. This will bring a lot of unnecessary trouble.

created at:08-18-2021
edited at: 08-18-2021: