Skip to main content

Python wrapper for polymake

Project description

What is it?

The Python module pypolymake provides wrappers for polymake version 3.1. This module will not compile with older version of polymake.

The language has been kept as close as possible as the original. The following polymake construction:

polytope> $c = cube(5);
polytope> print $c->F_VECTOR;
32 80 80 40 10
polytope> $g = $c->GRAPH;
polytope> print $g->DIAMETER;

is translated in Python as:

>>> from polymake import *
>>> c = cube(5)
>>> print(c.F_VECTOR)
(32, 80, 80, 40, 10)
>>> g = c.GRAPH
>>> print(g.DIAMETER)

The library is currently under development and is compatible with Python2 and Python3. As it is under development, many things are not working and are likely to break.

Installation and source code

Just run the following command to install pypolymake

$ pip install git+ [–user] [–upgrade]

If you want to use it inside Sage, you need a version more recent than Sage 8.0.beta0 (earlier versions ships polymake version 2.7, not compatible with pypolymake). To install polymake and pypolymake run

$ sage -i polymake $ sage -pip install git+ [–user] [–upgrade]

### Notes

If polymake headers or libraries are installed in a non standard location you may need to set the environment variables CFLAGS, CXXFLAGS, LDFLAGS. For example, on OS X, you need to update LDFLAGS as:

$ export LDFLAGS="-L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/ $LDFLAGS"
$ python install --user

You might also need to set LD_LIBRARY_PATH before starting Python if the shared library of polymake ( is not in a standard directory. For example

$ LD_LIBRARY_PATH=/my/path/to/lib/ ipython

For SageMath users

If pypolymake is used inside SageMath then conversion from and to sage objects are available. Most polymake objects have a .sage() method and you can use polymake.polymake as a generic convertor. For example:

sage: import polymake
sage: p = polymake.polymake(polytopes.dodecahedron())
sage: p
sage: p.VERTICES
1 3-1r5 3-1r5 3-1r5
1 -1+1r5 -4+2r5 0
1 -3+1r5 -3+1r5 -3+1r5
1 1-1r5 4-2r5 0
sage: print(p.VERTICES.sage())
[           1   -sqrt5 + 3   -sqrt5 + 3   -sqrt5 + 3]
[           1    sqrt5 - 1  2*sqrt5 - 4            0]
[           1    sqrt5 - 3    sqrt5 - 3    sqrt5 - 3]
[           1   -sqrt5 + 1 -2*sqrt5 + 4            0]

Warning: the cohabitation between sage and polymake is not perfect. If you do use polymake in sage always import sage first and then polymake. More precisely, if you launch a simple python console and do ‘import polymake’ followed by ‘import sage.all’ it is most likely to end up with a (not yet identified) SEGFAULT.


The library pypolymake is distributed under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version (see


This project has been started by Burcin Erocal in 2011 and continued by Vincent Delecroix in 2016

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypolymake-0.1b6.tar.gz (115.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page