Search code examples
python-importjythonjython-2.5

Jython: where is itertools?


In Jython 2.5.3, trying to import itertools:

>>> from itertools import product
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name product

Yet if you see this page from Jython docs itertools looks a core part of Jython since 2.3.

What do I need on the syspath to import iterools?


Solution

  • itertools.product is not available in Jython 2.5. The function was added in CPython 2.6, and is available in Jython 2.7.

    See also https://wiki.python.org/jython/JythonFaq/GeneralInfo#Is_Jython_the_same_language_as_Python.3F.