doctest import failure

j vickroy jim.vickroy at noaa.gov
Thu Aug 29 17:15:07 EDT 2002


Thanks Tim.

The suggestion to run Python -v was perfect: I must read about these command
line options!

It revealed an old copy of inspect.py on a hard drive I had not searched
because there was no way the Python interpreter could find it there <sigh>.
I still do not
understand how it was found because I supposedly do not define PYTHONPATH so
that everything used is in \PYTHON22\LIB\site-packages.

Thanks again.





"Tim Peters" <tim.one at comcast.net> wrote in message
news:mailman.1030652566.31752.python-list at python.org...
> [j vickroy]
> > The doctest module is not working on my installation.  Here is a sample
> > session:
> >
> > D:\my-py-pkgs\generic-v2.0>python
> > Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import doctest
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in ?
> >   File "C:\Python22\lib\doctest.py", line 298, in ?
> >     from inspect import classify_class_attrs as _classify_class_attrs
> > ImportError: cannot import name classify_class_attrs
> > >>>
>
> Works fine here:
>
> C:\Python22>python
> Python 2.2.1 (#34, Apr  9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import doctest
> >>>
>
>
> > import inspect
> > >>> dir(inspect)
> > ['BlockFinder', 'CO_NEWLOCALS', 'CO_OPTIMIZED', 'CO_VARARGS',
> > 'CO_VARKEYWORDS', 'EndOfBlock', 'ListReader', '__author__',
> > '__builtins__',
> > '__date__', '__doc__', '__file__', '__name__', 'currentframe', 'dis',
> > 'findsource', 'formatargspec', 'formatargvalues', 'getabsfile',
'getargs',
> > 'getargspec', 'getargvalues', 'getblock', 'getclasstree', 'getcomments',
> > 'getdoc', 'getfile', 'getframeinfo', 'getinnerframes', 'getlineno',
> > 'getmembers', 'getmodule', 'getmoduleinfo', 'getmodulename',
> > 'getouterframes', 'getsource', 'getsourcefile', 'getsourcelines', 'imp',
> > 'indentsize', 'isbuiltin', 'isclass', 'iscode', 'isframe', 'isfunction',
> > 'ismethod', 'ismodule', 'isroutine', 'istraceback', 'joinseq',
> > 'modulesbyfile', 'os', 're', 'stack', 'string', 'strseq', 'sys',
> > 'tokenize',
> > 'trace', 'types', 'walktree']
> > >>>
>
> This doesn't look rigbt.  It's missing several routines from the 2.2.1
> inspect.py.  Run "python -v" to see where you're getting this file from.
>
> C:\Python22>python -v
> ... [output supressed] ...
> >>> import inspect
> # C:\Python22\lib\inspect.pyc matches C:\Python22\lib\inspect.py
> import inspect # precompiled from C:\Python22\lib\inspect.pyc
> # C:\Python22\lib\string.pyc matches C:\Python22\lib\string.py
> import string # precompiled from C:\Python22\lib\string.pyc
> import strop # builtin
> # C:\Python22\lib\re.pyc matches C:\Python22\lib\re.py
> import re # precompiled from C:\Python22\lib\re.pyc
> # C:\Python22\lib\sre.pyc matches C:\Python22\lib\sre.py
> import sre # precompiled from C:\Python22\lib\sre.pyc
> # C:\Python22\lib\sre_compile.pyc matches C:\Python22\lib\sre_compile.py
> import sre_compile # precompiled from C:\Python22\lib\sre_compile.pyc
> import _sre # dynamically loaded from C:\Python22\DLLs\_sre.pyd
> # C:\Python22\lib\sre_constants.pyc matches
C:\Python22\lib\sre_constants.py
> import sre_constants # precompiled from C:\Python22\lib\sre_constants.pyc
> # C:\Python22\lib\sre_parse.pyc matches C:\Python22\lib\sre_parse.py
> import sre_parse # precompiled from C:\Python22\lib\sre_parse.pyc
> # C:\Python22\lib\dis.pyc matches C:\Python22\lib\dis.py
> import dis # precompiled from C:\Python22\lib\dis.pyc
> import imp # builtin
> # C:\Python22\lib\tokenize.pyc matches C:\Python22\lib\tokenize.py
> import tokenize # precompiled from C:\Python22\lib\tokenize.pyc
> # C:\Python22\lib\token.pyc matches C:\Python22\lib\token.py
> import token # precompiled from C:\Python22\lib\token.pyc
> >>> inspect.classify_class_attrs
> <function classify_class_attrs at 0x007DF190>
> >>>
>
> > Is the inspect module, in my installation, incomplete?
>
> It's more likely that you're picking up some other version of inspect.py
> from earlier (than C:\Python22\lib\) on your search path.  This is
> especially likely because you're not running Python from a normal location
> (D:\my-py-pkgs\generic-v2.0 is something you made up on your own <wink>).
>
> > I installed Python using the MS Windows binary installer
> > (Python-2.2.1.exe)
> > downloaded from http://www.python.org/.
>
> Same here -- that doesn't account for it.
>
>





More information about the Python-list mailing list