{"id":8788,"library":"xpress","title":"FICO Xpress Optimizer Python Interface","description":"The FICO Xpress Optimizer Python interface (xpress) enables users to formulate, manage, and solve a comprehensive range of mathematical optimization problems including Linear Programming (LP), Quadratic Programming (QP), Second-Order Conic Programming (SOCP), and their mixed-integer counterparts (MILP, MIQP, MIQCQP, MISOCP), along with general nonlinear and mixed-integer nonlinear problems. It offers seamless integration with numerical libraries like NumPy and supports advanced features such as callbacks for solver control. The library is currently at version 9.8.1, with frequent updates including patches and minor versions released multiple times a year.","status":"active","version":"9.8.1","language":"en","source_language":"en","source_url":"https://github.com/fico-xpress/python-notebooks","tags":["optimization","mathematical programming","solver","LP","MIP","QP","SOCP","nonlinear programming","FICO Xpress"],"install":[{"cmd":"pip install xpress","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Provides underlying native Xpress Solver libraries, automatically installed by `pip install xpress`.","package":"xpresslibs","optional":false},{"reason":"Required for problem solving; a free Community License with size limits is included, or a full commercial license for larger problems.","package":"FICO Xpress License","optional":false}],"imports":[{"note":"Aliasing as 'xp' is a widely adopted convention for brevity and readability.","symbol":"xpress","correct":"import xpress as xp"}],"quickstart":{"code":"import xpress as xp\n\np = xp.problem(name='my_first_lp')\n\nx1 = p.addVariable(name='x1', lb=0, ub=xp.infinity)\nx2 = p.addVariable(name='x2', lb=0, ub=xp.infinity)\n\np.setObjective(3*x1 + 2*x2, sense=xp.minimize)\n\np.addConstraint(4*x1 + 2*x2 >= 10, name='c1')\np.addConstraint(x1 + x2 >= 3, name='c2')\n\np.optimize()\n\nif p.getProbStatus() == xp.lp_optimal:\n    print(f\"Solution Status: Optimal\")\n    print(f\"Objective Value: {p.getObjVal()}\")\n    print(f\"x1 = {p.getSolution(x1)}\")\n    print(f\"x2 = {p.getSolution(x2)}\")\nelse:\n    print(f\"Solution Status: {p.getProbStatusString()}\")","lang":"python","description":"This quickstart defines and solves a simple Linear Programming (LP) problem using the FICO Xpress Python interface. It initializes a problem, adds variables and constraints, sets an objective, and then optimizes the problem, printing the solution if optimal."},"warnings":[{"fix":"For larger problems, a commercial FICO Xpress license is necessary. Ensure the `XPRESS` environment variable points to the directory containing your `xpauth.xpr` license file.","message":"The `xpress` library, while installable via pip, requires an underlying FICO Xpress license to solve problems. A 'Community License' is included, but it imposes strict limits on problem size (e.g., sum of variables and linear constraints <= 5000, nonlinear tokens <= 1000).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check the console output or logs alongside the Python exception. The console typically contains the precise error message (e.g., 'Duplicate column names are not allowed').","message":"Generic `SystemError` or `RuntimeError` messages like `<built-in method [...] of xpress.problem object at [...]> returned NULL without setting an error` are frequently encountered in Jupyter notebooks or similar environments. These often obscure the actual, more descriptive error.","severity":"gotcha","affected_versions":"All versions (observed in 8.5.7 and later)"},{"fix":"Access these properties outside of callbacks or the presolve phase. If values are needed within a callback, store them in auxiliary data structures before the solve begins.","message":"Model properties on variable, constraint, and SOS objects (e.g., `var.lb`, `constraint.rhs`) are not accessible from within callbacks or while the problem is in a presolved state.","severity":"breaking","affected_versions":"9.4.5 and potentially later (introduced prior to 9.4.5)"},{"fix":"Users are advised to upgrade to Xpress 8.14.9 or a newer major release (e.g., 9.x). Archived versions may be available in the FICO Client area.","message":"Several older Xpress Python module versions (specifically 8.14.1, and 8.14.5 through 8.14.8) were removed from PyPI and Conda repositories on April 22, 2024.","severity":"deprecated","affected_versions":"8.14.1, 8.14.5, 8.14.6, 8.14.7, 8.14.8"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install xpress` to install the package. Ensure your Python environment is correctly set up and activated.","cause":"The `xpress` Python package has not been installed in the current environment, or the environment is not correctly activated.","error":"ModuleNotFoundError: No module named 'xpress'"},{"fix":"Verify that your license file is valid for your current platform and that the `XPRESS` environment variable is correctly set to the directory containing `xpauth.xpr`. Obtain a platform-appropriate license if necessary.","cause":"This error indicates a mismatch between the platform for which the Xpress license (`xpauth.xpr`) was generated and the current operating system (e.g., using a Windows license on Linux), or the license file is invalid/missing.","error":"xpress.InterfaceError: Xpress licensing error 89: Your license only supports platform(s) win32, win_x86_64. Please contact support@fico.com to upgrade it."},{"fix":"Check the terminal or IDE console output immediately preceding this error for a more descriptive message (e.g., '1030 Error: Duplicate column names are not allowed'). Correct the modeling mistake based on the detailed console error.","cause":"This generic Python error typically masks a more specific underlying Xpress API error, such as attempting to add a variable with a duplicate name or providing invalid arguments. The true error message is often logged to the console.","error":"SystemError: <built-in method addVariable of xpress.problem object at 0x...> returned NULL without setting an error"}]}