简体   繁体   中英

gdbm error 22 when performing Python shelve open

Doing a simple shelve.open will give the following error:


>>> shelve.open('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/shelve.py", line 243, in open
    return DbfilenameShelf(filename, flag, protocol, writeback)
  File "/usr/lib/python3.6/shelve.py", line 227, in __init__
    Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
  File "/usr/lib/python3.6/dbm/__init__.py", line 94, in open
    return mod.open(file, flag, mode)
_gdbm.error: [Errno 22] Invalid argument

I've only come across one related search result to this issue: https://github.com/pydanny/cookiecutter-django/issues/1793#issuecomment-440406112

I got exactly the same error on a Vagrant dev environment. Celery uses dbm for persistent storage, which is built on top of the gdbm C library. Some testing has revealed that this works when creating or opening files on a native filesystem but not on a mounted filesystem.

I'm running this under a Vagrant Ubuntu box in MacOS so it makes sense. I have also run the same box under Windows 10 and this issue doesn't crop up. Any clues for a fix?

I had the same issue and couldn't find any help online until I came across this post

https://github.com/we45/ThreatPlaybook/issues/11

creating a new virtual environment worked for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM