can't import generators
tim.one at comcast.net
Sun Jun 30 03:22:07 CEST 2002
> 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.
__future__.py 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 __future__.py for 2.2.1:
>>> import __future__
['CO_FUTURE_DIVISION', 'CO_GENERATOR_ALLOWED', 'CO_NESTED',
'_Feature', '__all__', '__builtins__', '__doc__', '__file__',
'__name__', 'all_feature_names', 'division', 'generators',
_Feature((2, 2, 0, 'alpha', 1), (2, 3, 0, 'final', 0), 4096)
More information about the Python-list