Registry / data / amplpy

amplpy

JSON →
library0.16.1pypypi✓ verified 85d ago

amplpy is the official Python API for AMPL, a powerful algebraic modeling language for optimization. Version 0.16.0 provides a Pythonic interface to define models, solve them with AMPL's solvers, and manipulate results. It is maintained by AMPL Inc. and follows a regular release cadence aligned with AMPL updates.

pip install amplpy
INSTALL
IMPORT
SIG · AMPLPY
A
amplpy
datapythonv0.16.1
Install
2.6s avg
Import
120ms
Disk
29MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.16.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
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.6s · import 0.120s · 30MB
29MB installed
● package 29MB
Code
Verified usage

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

AMPL
from amplpy import AMPL
import amplpy amplpy.AMPL()
Namespace import unnecessary; direct import is standard
DataFrame
from amplpy import DataFrame
from pandas import DataFrame
AMPL DataFrame is separate from pandas DataFrame; using pandas will cause errors
Environment
from amplpy import Environment

Create an AMPL instance, evaluate a simple model, solve it, and print the objective value.

from amplpy import AMPL, DataFrame ampl = AMPL() ampl.eval('var x; maximize obj: x; subject to c: x <= 1;') ampl.solve() print('Objective:', ampl.getValue('obj'))
amplpy --version
Debug
Known issues
breakingIn amplpy 0.13.0 and later, the `amplpy.AMPL` constructor no longer accepts `ampl_bin` or `format` arguments; use `Environment` to set AMPL path.
fix
Use `Environment(ampl_bin='/path/to/ampl')` and pass to `AMPL(environment=env)`.
affects: >=0.13.0
gotchaWhen using AMPL DataFrame with pandas DataFrames, the column names may be automatically converted to strings; mixing types can cause silent data loss.
fix
Ensure all column names in pandas DataFrames are strings before converting to AMPL DataFrame.
affects: all
deprecatedThe method `getData(name)` is deprecated in favor of `get_data(name)` (underscore convention) since version 0.12.0.
fix
Replace `getData('x')` with `get_data('x')`.
affects: >=0.12.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'amplpy'
amplpy is not installed, or installed in a different Python environment.
fix
Run `pip install amplpy` in the correct environment (e.g., virtualenv).
RuntimeError: AMPL executable not found. Please set the AMPL path
AMPL is not installed or not in PATH, and amplpy cannot locate the AMPL executable.
fix
Set the AMPL path via environment variable `AMPLBIN` or pass `Environment(ampl_bin='/path/to/ampl')` to the `AMPL` constructor.
TypeError: No matching signature found
Using numpy or pandas data types that are not supported by AMPL's C++ interface; often due to using pandas DataFrames with non-string column names.
fix
Convert column names to strings and ensure data types are basic (int, float, str).
Upgrade
Version history
0.16.1latest on PyPI · released May 26, 2026
Audit
Dependencies
numpyoptionalUsed for array data handling in data frames and entity values
Agent activity
47 hits · last 30 days
node
38
OpenAI (training)
1
Resources
amplpy — pip install amplpy · libregistry