
Research
/Security News
Fake imToken Chrome Extension Steals Seed Phrases via Phishing Redirects
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.
pymzn
Advanced tools
PyMzn is a Python library that wraps and enhances the MiniZinc tools for constraint programming. PyMzn is built on top of the minizinc toolkit and provides a number of off-the-shelf functions to readily solve problems encoded with the MiniZinc language and return solutions as Python dictionaries.
First, we need to define a constraint program via MiniZinc. Here is a simple 0-1 knapsack problem encoded with MiniZinc:
%% knapsack01.mzn %%
int: n; % number of objects
set of int: OBJ = 1..n;
int: capacity; % the capacity of the knapsack
array[OBJ] of int: profit; % the profit of each object
array[OBJ] of int: size; % the size of each object
var set of OBJ: x;
constraint sum(i in x)(size[i]) <= capacity;
var int: obj = sum(i in x)(profit[i]);
solve maximize obj;
%% knapsack01.dzn %%
n = 5;
profit = [10, 3, 9, 4, 8];
size = [14, 4, 10, 6, 9];
You can solve the above problem using the pymzn.minizinc function:
import pymzn
solns = pymzn.minizinc('knapsack01.mzn', 'knapsack01.dzn', data={'capacity': 20})
print(solns)
The result will be:
[{'x': {3, 5}}]
The returned object is a lazy solution stream, which can either be iterated or
directly indexed as a list. The pymzn.minizinc function takes care of all the
preprocessing, the communication with the minizinc executable, and the parsing
of the solutions stream into Python dictionaries.
PyMzn is also able to:
pymzn.minizinc function);For a follow-up of the previous example, read the PyMzn tutorial.
For more information on the PyMzn classes and functions refer to the reference manual.
PyMzn can be installed via Pip:
pip install pymzn
or from the source code available on GitHub:
python setup.py install
PyMzn is developed and maintained in Python 3.5. Starting from version 0.18.0,
support for Python 2 and versions previous to 3.5 has been dropped (its just too
much work mainintaining them). Using the package pymzn.aio for concurrent
execution requires Python 3.6 (though it is optional).
PyMzn requires the MiniZinc toolkit to be installed on your machine. Starting from PyMzn 0.18.0, the minimum MiniZinc version required is the 2.2.0. If you need to work with previous versions of MiniZinc, PyMzn 0.17.1 should work fine.
The easiest way to install MiniZinc is to download the
MiniZincIDE package, which
contains both the MiniZinc binaries and several solvers. After downloading the
package, make sure the executables are visible to PyMzn either by setting the
PATH environment variable or by configuring it using the pymzn.config
module.
For more details take a look at the Install section in the documentation.
Optional dependencies include:
Paolo Dragone, PhD student at the University of Trento (Italy).
FAQs
A Python wrapper for the MiniZinc tool pipeline.
We found that pymzn demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.

Security News
Latio’s 2026 report recognizes Socket as a Supply Chain Innovator and highlights our work in 0-day malware detection, SCA, and auto-patching.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.