docplex.mp.environment module

Provides utility functions about the runtime environment.

You can display information about your runtime environment using:

$ python
>>> from docplex.mp.environment import Environment
>>> Environment().print_information()

or by invoking the docplex.mp.environment package on your shell command line:

$ python -m docplex.mp.environment
* system is: Linux 64bit
* Python version 3.6.1, located at: /usr/bin/python
* docplex is present, version is (2, 9, 0)
* CPLEX library is present, version is 12.9.0.0, located at: /usr/local/CPLEX_Studio129/cplex/python/3.6/x86-64_linux
class docplex.mp.environment.Environment(start_auto_configure=True, logger=None)[source]

Bases: object

This class detects and contains information regarding other modules of interest, such as whether CPLEX, numpy, and matplotlib are installed.

cplex_location

The system path where CPLEX is located, if present. Otherwise, returns None.

get_cplex_module(default_location=None, logger=None)[source]

Returns the cplex module.

If default_location is None, this method will try to import the cplex module in the following order:

  • by importing the module import cplex if the import is sucessful
  • by importing the module in location $CPLEX_STUDIO_DIR20101/cplex/python
  • by importing the module in location $CPLEX_STUDIO_DIR201/cplex/python
  • by importing the module in location $CPLEX_STUDIO_DIR1210/cplex/python
  • by importing the module in location $CPLEX_STUDIO_DIR129/cplex/python
  • by importing the module in location $CPLEX_STUDIO_DIR128/cplex/python

If default_location is a valid path and contains a valid python package, cplex is imported from the specified location.

If default_location is a valid path and <default_location>/cplex/python/<python_version>/<platform> exists, cplex is imported from that location

If cplex could not be found, this method returns None

has_cplex

True if the CPLEX libraries are available.

The cplex libraries search order is:

  • import the module import cplex if the import is sucessful
  • import the module in location $CPLEX_STUDIO_DIR1210/cplex/python/<python.version>/<platform>
  • import the module in location $CPLEX_STUDIO_DIR129/cplex/python/<python.version>/<platform>
  • import the module in location $CPLEX_STUDIO_DIR128/cplex/python/<python.version>/<platform>
has_matplotlib

True if the matplotlib libraries are available.

has_numpy

True if the numpy libraries are available.

has_pandas

True if the pandas libraries are available.

is_64bit()[source]

True if running on a 64-bit platform.

python_version

Returns the Python version as a string

exception docplex.mp.environment.UnsupportedPlatformError[source]

Bases: Exception