error at "import anydbm"

Peter Hansen peter at engcorp.com
Tue Jan 13 14:34:02 EST 2004


"Cédric V." wrote:
> I am unable to import anydbm without error under Python2.2 or 2.3 (Linux).
> 
> this script:
>  >#!/usr/bin/env python
>  >import anydbm
>  >
>  >if __name__ == "__main__":
>  >    db = anydbm.open("test", "rwc")
>  >    db["test"] = "ok"
> 
> returns at execution:
> 
>  >cedric at dev _test $ python dbm.py
>  >Traceback (most recent call last):
>  >  File "dbm.py", line 2, in ?
>  >    import anydbm
>  >  File "/usr/lib/python2.3/anydbm.py", line 59, in ?
>  >    _errors.append(_mod.error)
>  >AttributeError: 'module' object has no attribute 'error'

Do you have any modules of your own creation called any of the following?

  ['dbhash', 'gdbm', 'dbm', 'dumbdbm']

These are the names of the modules anydbm tries to import, and it appears
to expect each of them to have an "error" name defined.  Most likely your
module, with a conflicting name, is being found first and it does not
have an "error" attribute.

Generally speaking, you should try to avoid using the same names as
the standard library modules for your own code.

-Peter



More information about the Python-list mailing list