Install & Compatibility
Where this runs
tested against v1.15.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.248s · 107.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.9s · import 0.282s · 97MB
104MB installed
● package 104MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Highs
✓ import highspy
h = highspy.Highs()
HighsLp
✓ from highspy import HighsLp
lp = HighsLp()
ObjSense
✓ from highspy import ObjSense
lp.sense_ = ObjSense.kMaximize
✗ highspy.kMaximize
Enums are accessed via the enum class (e.g., ObjSense) within the highspy module, not directly as module-level constants.
This quickstart demonstrates how to define and solve a simple Linear Programming (LP) problem using `highspy`. It constructs an `HighsLp` object, populates it with objective coefficients, variable bounds, and constraint matrix, then passes it to the HiGHS solver instance to find an optimal solution.
import highspy
import numpy as np
h = highspy.Highs()
# Define an LP problem (maximize 8x0 + 10x1 subject to constraints)
lp = highspy.HighsLp()
lp.num_col_ = 2
lp.num_row_ = 2
lp.sense_ = highspy.ObjSense.kMaximize
lp.col_cost_ = np.array([8, 10], dtype=np.double)
lp.col_lower_ = np.array([0, 0], dtype=np.double)
lp.col_upper_ = np.array([highspy.kHighsInf, highspy.kHighsInf], dtype=np.double)
lp.row_lower_ = np.array([-highspy.kHighsInf, -highspy.kHighsInf], dtype=np.double)
lp.row_upper_ = np.array([120, 210], dtype=np.double)
# Constraint matrix A (row-wise in this example for illustration)
# 0.3*x0 + 0.5*x1 <= 120
# 0.7*x0 + 0.5*x1 <= 210
lp.a_matrix_.start_ = np.array([0, 2, 4]) # Column starts (for column-wise storage, but example uses row-wise interpretation)
lp.a_matrix_.index_ = np.array([0, 1, 0, 1]) # Row indices for each element
lp.a_matrix_.value_ = np.array([0.3, 0.7, 0.5, 0.5], dtype=np.double)
h.passModel(lp)
# Solve the model
h.run()
# Extract and print solution
solution = h.getSolution()
info = h.getInfo()
model_status = h.getModelStatus()
print(f"Model status: {h.modelStatusToString(model_status)}")
if model_status == highspy.HighsModelStatus.kOptimal:
col_value = list(solution.col_value)
print(f"Optimal objective: {info.obj_val}")
print(f"x0 = {col_value[0]}, x1 = {col_value[1]}")
else:
print("No optimal solution found.")
Debug
Known issues
gotchaDirect iteration or element-wise access of returned array-like solution values (e.g., `solution.col_value`) can be very slow. It is highly recommended to convert these to Python lists first for efficient access.fixConvert solution arrays to lists: `col_value = list(solution.col_value)` before accessing elements.
affects: All versions
gotchaWhen constructing linear expressions, the `highs_linear_expression.__add__` method modifies the expression in-place. Reusing an expression object after it has been modified can lead to unexpected and hard-to-debug results.fixIf an expression needs to be reused, ensure you are working with a copy or construct expressions explicitly for each use. More robust expression building might be available in newer versions (e.g., `ExprBuilder` mentioned in related discussions).
affects: Versions prior to 1.14.0, and potentially current if not careful.
gotchaBy default, HiGHS C++ logging is duplicated to `Highs.log`. In `highspy`, to redirect logging output to a specific file, you must explicitly set the 'log_file' option.fixUse `h.setOptionValue('log_file', 'your_log_file.txt')` on your `highspy.Highs` instance to specify a log file. affects: All versions
gotchaUsers integrating `highspy` with other modeling libraries like `python-mip` might encounter `FileNotFoundError: HiGHS not found` even after `highspy` is installed. This suggests a solver discovery issue in the integrating library.fixConsult the documentation of the integrating modeling library. It may require setting an environment variable like `PMIP_HIGHS_LIBRARY` to explicitly point to the HiGHS shared library.
affects: Observed with `python-mip` v1.9.0 and earlier.
deprecatedThe `addVar` method within the direct `highspy` modeling interface was noted for clashes and potential confusion with internal methods. A new method, `addVariable`, is being introduced for clearer high-level modeling.fixFor high-level modeling, prefer `addVariable` and `addConstr` if available in your `highspy` version. For direct interaction with the solver's underlying data structures, use `addCol` and `addRow`.
affects: Versions 1.5.3, 1.7.1.dev1, and potentially others. Users attempting to use `addVar` for high-level modeling might experience issues.
Errors
Common errors & fixes
ImportError: DLL load failed while importing highs_bindings: The specified procedure could not be found.
This error typically occurs on Windows when the `highspy` Python package cannot load its underlying C++ shared library (DLL), often due to missing Microsoft Visual C++ Redistributable packages or environmental issues within a Python environment like Anaconda.
fixFor Windows, ensure the Microsoft Visual C++ Redistributable for Visual Studio 2015-2022 is installed. If using a `conda` environment, explicitly activate it before running your Python script. Reinstalling `highspy` in a clean virtual environment can also resolve the issue.
ImportError: dlopen(.../highs_bindings.cpython-xxx-darwin.so, 0x0002): symbol not found in flat namespace '__ZN5Highs10clearModelEv'.
This `ImportError` on macOS indicates a problem with the dynamic linking of the `highspy` shared library, where a required symbol (like a specific C++ function) is not found. This can happen if `highspy` was installed via `conda` rather than `pip`, or if there are version mismatches.
fixIt is recommended to install `highspy` using `pip` (`pip install highspy`) and avoid `conda` for `highspy` specifically, as `pip` installations are officially supported and tend to resolve these linking issues on macOS. Ensure `pip` and `setuptools` are up to date before installing.
AttributeError: 'Highs' object has no attribute 'addConstr'
This error arises when a user attempts to use a modeling API style (like `addConstr` for adding constraints) that is common in higher-level optimization modeling libraries (e.g., Pyomo, Gurobi) but is not directly available in `highspy`'s lower-level Python bindings to HiGHS. The `highspy` library exposes a direct interface to the HiGHS solver's C++ API.
fixConstruct the optimization model using `highspy`'s explicit API by populating a `highspy.HighsModel` object. This involves setting attributes such as `col_lower`, `col_upper`, `row_lower`, `row_upper`, `a_matrix_start`, `a_matrix_index`, `a_matrix_value`, and `obj_coeffs` directly, rather than using convenience methods like `addConstr`. Refer to the official `highspy` examples for correct model formulation.
FileNotFoundError: HiGHS not found. Please install the `highspy` package, or set the `PMIP_HIGHS_LIBRARY` environment variable.
This specific error occurs when using `python-mip` with `highspy` and `python-mip` cannot locate the HiGHS solver's shared library or executable, even if `highspy` is installed. This often indicates that `python-mip` needs to be explicitly told where the HiGHS library resides.
fixFirst, ensure `highspy` is installed (`pip install highspy`). If the error persists, set the `PMIP_HIGHS_LIBRARY` environment variable to the full path of the `highs_bindings` shared library file within your `highspy` installation (e.g., `C:\path\to\venv\Lib\site-packages\highspy\_core.cpXX-win_amd64.pyd` on Windows or `.so`/`.dylib` on Linux/macOS).
Upgrade
Version history
1.15.1latest on PyPI · released Jul 2, 2026
Audit
Dependencies
numpyrequiredRequired for numerical array operations and data handling.