简体   繁体   English

执行 Python 搁置打开时出现 gdbm 错误 22

[英]gdbm error 22 when performing Python shelve open

Doing a simple shelve.open will give the following error:做一个简单的shelve.open会出现以下错误:


>>> 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我只遇到过一个与此问题相关的搜索结果: https : //github.com/pydanny/cookiecutter-django/issues/1793#issuecomment-440406112

I got exactly the same error on a Vagrant dev environment.我在 Vagrant 开发环境中遇到了完全相同的错误。 Celery uses dbm for persistent storage, which is built on top of the gdbm C library. Celery 使用 dbm 进行持久存储,它构建在 gdbm C 库之上。 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.我在 MacOS 的 Vagrant Ubuntu 盒子下运行它,所以它是有道理的。 I have also run the same box under Windows 10 and this issue doesn't crop up.我也在 Windows 10 下运行了同一个盒子,但没有出现这个问题。 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 https://github.com/we45/ThreatPlaybook/issues/11

creating a new virtual environment worked for me创建一个新的虚拟环境对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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