Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#10 Attribute error when loading module

open
nobody
None
5
2004-11-21
2004-11-21
Anonymous
No

When I do "from wordnet import *" I get:
Exception exceptions.AttributeError: "DbfilenameShelf
instance has no attribute 'writeback'" in ignored
Exception exceptions.AttributeError: "DbfilenameShelf
instance has no attribute 'writeback'" in ignored
Exception exceptions.AttributeError: "DbfilenameShelf
instance has no attribute 'writeback'" in ignored
Exception exceptions.AttributeError: "DbfilenameShelf
instance has no attribute 'writeback'" in ignored

The software seems to work fine, but the exceptions
shoudn't be there, I dont' think.

Discussion

  • Logged In: YES
    user_id=1176098

    I am also facing this problem. That doesn't creates problem
    as long as we are using in command prompt. But my apache is
    giving error and is not able to import that because of those
    warnings. I am using pywordnet in cgi. Is there any hack or
    patch around so that I can get rid of these errors?

     
  • c.libre
    c.libre
    2005-09-09

    Logged In: YES
    user_id=1138768

    I've tried this on a Debian 3.0 system with Python 2.2.1 and
    Python 2.3.5, and this doesn't occur on 2.2.1, for what it's
    worth.

     
  • Logged In: NO

    From
    http://www-128.ibm.com/developerworks/xml/library/x-think29.html

    "I think this error message is caused by a well-known bit of
    awkwardness in the Python shelve module, which reads the
    sort of hash database files that are used for WordNet. I was
    able to proceed without problems despite these messages."

     
  • Nick Gasson
    Nick Gasson
    2006-07-15

    Logged In: YES
    user_id=1395866

    I found I could make the error messages disappear by adding
    this line to wordnet.py:

    from anydbm import error

     
  • Nick Gasson
    Nick Gasson
    2006-07-16

    Logged In: YES
    user_id=1395866

    Er... ignore that last message :-). Here's a patch that
    acutally works. Uses whichdb to work out whether the db file
    is valid before trying to open it:

    --- /Users/nick/Documents/wordnet.py.base 2006-07-16
    18:07:19.000000000 +0100
    +++ wordnet.py 2006-07-16 18:08:23.000000000 +0100
    @@ -956,7 +956,9 @@
    self.shelfname = os.path.join(WNSEARCHDIR, pos +
    ".pyidx")
    try:
    import shelve
    - self.indexCache = shelve.open(self.shelfname, 'r')
    + from whichdb import whichdb
    + if whichdb(self.shelfname):
    + self.indexCache =
    shelve.open(self.shelfname, 'r')
    except:
    pass

     
  • Logged In: YES
    user_id=1084025

    The patch shown below doesn't work as is on my version
    (2.0.1) because the line numbers are off. But if you
    hand-edit the file and make the changes as shown, the error
    goes away and pywordnet continues to work. Thanks.

     
  • Logged In: NO

    to silence this, below the line:
    import shelve
    add the line:
    import anydbm.error
    (at the same indentation level)
    Supposedly this will be fixed in python versions > 2.4.3 (it
    is a bug in shelve)