[Tutor] AttributeError:

Peter Otten __peter__ at web.de
Fri Jul 19 21:39:59 CEST 2013


Charles McAndrews wrote:

> Whenever I try to type 'python' into the cmd prompt, it always gives me
> this error:
> 
> Traceback (most recent call last):
>   File "C:\Python27\lib\site.py", line 62, in <module>
>     import os
>   File "C:\Python27\lib\os.py", line 398, in <module>
>     import UserDict
>   File "C:\Python27\lib\UserDict.py", line 83, in <module>
>     import _abcoll
>   File "C:\Python27\lib\_abcoll.py", line 70, in <module>
>     Iterable.register(str)
>   File "C:\Python27\lib\abc.py", line 107, in register
>     if not isinstance(subclass, (type, types.ClassType)):
> AttributeError: 'module' object has no attribute 'ClassType'

You have a file types.py, perhaps written by yourself, which Python imports 
instead of the types module in the standard library. Try invoking Python 
with the -S option:

python -S

If that gets you into the interactive interpreter do

>>> import types
>>> types.__file__
'yadda/types.pyc'

Instead of yadda/types.pyc you will see the path of the actual file that 
hides the types module of the stdlib on your system.

Remove that types.pyc, rename the corresponding types.py, and you should be 
able to start python in the usual way again.



More information about the Tutor mailing list