Registry / data / pulp
library3.3.2pypypi✓ verified 26d ago

PuLP is an LP (Linear Programming) modeler written in Python. It simplifies the creation of linear and mixed-integer programming optimization problems, allowing users to define problems using Pythonic syntax. It can generate MPS or LP files and call various open-source (like GLPK, COIN-OR CBC, HiGHS, SCIP) or proprietary (CPLEX, GUROBI, MOSEK, XPRESS) solvers to find optimal solutions. The current version is 3.3.0, and it is actively maintained with regular updates.

pip install pulp
INSTALL
IMPORT
SIG · PULP
P
pulp
datapythonv3.3.2
Install
3.0s avg
Import
186ms
Disk
52MB
Pass rate
7/ 10
Env Coverage7 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.3.2 · 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
musl
glibc
py 3.10
✓ —
✓ 2.15s
py 3.11
1/2 runs
✓ 3.9s
py 3.12
1/2 runs
✓ 3.2s
py 3.13
1/2 runs
✓ 3.35s
py 3.9
✓ —
✓ 2.4s
52MB installed
● package 52MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LpProblem
from pulp import LpProblem
LpVariable
from pulp import LpVariable
LpMinimize
from pulp import LpMinimize
LpMaximize
from pulp import LpMaximize
lpSum
from pulp import lpSum
*
from pulp import LpProblem, LpVariable, LpMinimize, lpSum, LpStatus, value
from pulp import *
While common in examples for brevity, importing all symbols into the global namespace can lead to name clashes in larger projects. Explicit imports are recommended for clarity and avoiding conflicts.

This quickstart demonstrates how to define and solve a simple integer linear programming problem using PuLP. It covers creating a problem, defining decision variables with bounds and categories, setting an objective function, adding constraints, and finally solving the problem to display the optimal solution and variable values.

from pulp import LpProblem, LpVariable, LpMinimize, lpSum, LpStatus, value # 1. Create the problem variable, specifying minimization or maximization prob = LpProblem("My Production Problem", LpMinimize) # 2. Define decision variables x = LpVariable("Product_A", lowBound=0, cat='Integer') y = LpVariable("Product_B", lowBound=0, cat='Integer') # 3. Define the objective function (e.g., minimize cost) prob += 3 * x + 2 * y, "Total Cost" # 4. Define constraints prob += 2 * x + y >= 10, "Minimum Production" prob += x + y <= 12, "Max Capacity" prob += x >= 4, "Min Product A" # 5. Solve the problem status = prob.solve() # 6. Print the results print(f"Status: {LpStatus[status]}") if LpStatus[status] == "Optimal": print(f"Optimal Total Cost: {value(prob.objective)}") print(f"Units of Product A: {value(x)}") print(f"Units of Product B: {value(y)}") else: print("No optimal solution found.")
Debug
Known issues
gotchaPuLP is a modeling library and relies on external solvers to find solutions. While the COIN-OR CBC solver is included by default, other more powerful solvers (like CPLEX, Gurobi, HiGHS, SCIP) require separate installation, often via specific `pip install pulp[solver_name]` commands. Some proprietary solvers also require valid licenses.
fix
Identify required solver; install with `pip install pulp[solver_name]` (e.g., `pip install pulp[highs]`); ensure necessary licenses are acquired for commercial solvers. Refer to PuLP documentation for solver configuration.
affects: All versions
gotchaPuLP is designed specifically for Linear Programming (LP) and Mixed-Integer Linear Programming (MILP) problems. It cannot be used to model or solve non-linear optimization problems.
fix
For non-linear problems, consider alternative Python optimization libraries such as SciPy's `minimize` for general non-linear optimization or Pyomo for advanced modeling capabilities that extend beyond linearity.
affects: All versions
breakingPuLP requires Python 3.9 or newer. Older Python versions are not supported, and attempting to install or run PuLP with them will result in errors.
fix
Upgrade your Python environment to Python 3.9 or a newer compatible version.
affects: <3.9
gotchaOn Linux and macOS systems, the default COIN-OR CBC solver (included with PuLP) might require executable permissions to run tests or solve problems. The documentation suggests running `sudo pulptest`.
fix
After installing PuLP, run `sudo pulptest` in your terminal to ensure the default solver is executable. This command is often used to run solver tests, which implicitly checks executability.
affects: All versions on Linux/macOS
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pulp'
The PuLP library is not installed in the Python environment being used, or the Python interpreter cannot find it.
fix
Install PuLP using pip: `pip install pulp`. If using Anaconda, consider `conda install -c conda-forge pulp`.
pulp.solvers.PulpSolverError: Pulp: Error while trying to execute
The solver executable (e.g., cbc.exe, glpsol.exe) is not found in the system's PATH, or PuLP cannot execute it due to permissions or an incorrect path. This can also happen if there are very large numbers or duplicated variables/constraints in the model.
fix
Ensure the solver (like CBC, which is usually bundled) is accessible. For specific solvers, you might need to install them separately and provide the path: `prob.solve(pulp.GLPK_CMD(path='/path/to/glpsol.exe'))`. For debugging, use `prob.solve(PULP_CBC_CMD(msg=1))` to get more detailed solver output.
AttributeError: module 'pulp' has no attribute 'list_solvers'
The `list_solvers` function was deprecated in PuLP version 2.8.0 and replaced with `listSolvers`.
fix
Update your code to use `pulp.listSolvers()` instead of `pulp.list_solvers()`. If you need to use older code, downgrade PuLP to a version prior to 2.8.0 with `pip install 'pulp<2.8'`.
LpStatus[-1] 'Infeasible'
This status indicates that the optimization problem, as formulated, has no solution that satisfies all the given constraints.
fix
Review your model's objective function and constraints for contradictions. Try removing constraints one by one to identify which ones are causing the infeasibility. Consider adding slack variables or adjusting bounds. Generating an LP file with `prob.writeLP('problem.lp')` can also help in debugging.
AttributeError: 'NoneType' object has no attribute 'actualSolve'
This error typically occurs when the `solve()` method is called on a problem object (`prob`) before a solver has been successfully associated with it, resulting in the solver object being `None`. This often stems from the default solver (CBC) not being found or initialized properly during PuLP installation.
fix
Ensure PuLP is correctly installed and its default solver (CBC) is available. Reinstalling PuLP (`pip uninstall pulp` then `pip install pulp`) often resolves this. You can explicitly set a solver using `prob.setSolver(pulp.PULP_CBC_CMD())` before calling `prob.solve()`. You can check available solvers using `pulp.listSolvers(onlyAvailable=True)`.
Upgrade
Version history
3.3.2latest on PyPI · released May 25, 2026
Audit
Dependencies
cylpoptionalOptional dependency for using CyLP solver.
highspyoptionalOptional dependency for using HiGHS solver.
gurobipyoptionalOptional dependency for using Gurobi solver (requires separate license).
cplexoptionalOptional dependency for using CPLEX solver (requires separate license).
Agent activity
79 hits · last 30 days
node
74
OpenAI (training)
1
Resources
pulp — pip install pulp · libregistry