can't import generators

Tim Peters at
Sun Jun 30 03:22:07 CEST 2002

[John Hunter]
> I am having trouble working with generators.  Anyone know what might
> cause this behavior:
> > /usr/local/bin/python2.2
> Python 2.2.1 (#1, Apr 22 2002, 21:20:54)
> [GCC 3.0.4] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from __future__ import generators
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> ImportError: cannot import name generators
> >>>

Start Python with the -v switch to see how imports are getting resolved. is an actual module that actually gets imported.  If you're
picking up a wrong version of the Python libraries, that would explain it
(maybe due to a bad PYTHONPATH setting, or some local module named

Note that you *are* successfully importing *some* module named __future__,
else the error msg would have been different.

Here's what's in the correct for 2.2.1:

>>> import __future__
>>> dir(__future__)
 '_Feature', '__all__', '__builtins__', '__doc__', '__file__',
 '__name__', 'all_feature_names', 'division', 'generators',
>>> __future__.generators
_Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 4096)

More information about the Python-list mailing list