python - 在 macOS 上为 Python 3.6.8 使用 dbm.gnu
问题描述
我在 macOS 上为 Python 3.6.8 使用 dbm.gnu 时遇到了一些问题。我已经使用 conda 在我的 Python 虚拟环境中安装了 gdbm...但是在尝试调用 dbm.gnu 时收到以下错误消息:
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-2-11fcf8fc693c> in <module>
1 # Downloads the HI data in a fits file format
2 hi_datafile = download_file('http://cdsarc.u-strasbg.fr/vizier/ftp/cats/J/A+A/594/A116/CUBES/GAL/TAN/TAN_C14.fits',
----> 3 cache = True, show_progress = True)
/anaconda3/envs/py36-stable/lib/python3.6/site-packages/astropy/utils/data.py in download_file(remote_url, cache, show_progress, timeout)
1010 if cache:
1011 # We don't need to acquire the lock here, since we are only reading
-> 1012 with shelve.open(urlmapfn) as url2hash:
1013 if url_key in url2hash:
1014 return url2hash[url_key]
/anaconda3/envs/py36-stable/lib/python3.6/shelve.py in open(filename, flag, protocol, writeback)
241 """
242
--> 243 return DbfilenameShelf(filename, flag, protocol, writeback)
/anaconda3/envs/py36-stable/lib/python3.6/shelve.py in __init__(self, filename, flag, protocol, writeback)
225 def __init__(self, filename, flag='c', protocol=None, writeback=False):
226 import dbm
--> 227 Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
228
229
/anaconda3/envs/py36-stable/lib/python3.6/dbm/__init__.py in open(file, flag, mode)
89 elif result not in _modules:
90 raise error[0]("db type is {0}, but the module is not "
---> 91 "available".format(result))
92 else:
93 mod = _modules[result]
error: db type is dbm.gnu, but the module is not available
有什么可靠的方法可以让它工作吗?cache = False
从 astropy调用时,我可以通过设置来关闭缓存download_file
......但我真的很想设置cache = True
. 任何帮助将非常感激。
解决方案
所以我最终做了一些不明智但有效的事情,即更改“/anaconda3/envs/py36-stable/lib/python3.6/dbm/gnu.py”中的唯一行
from _gdbm import *
至
from _dbm import *
......这对我有用。
推荐阅读
- javascript - 谷歌地图 MarkerCluster 加 Spiderfier
- ios - 使用 XCode 中的 Shell 脚本将项目中的所有现有代码文件从 2 个空格缩进转换为 4 个空格缩进
- python - 具有不同行数的 Matplotlib 子图与颜色图和图例有关
- r - hist() 来自列表名称的主标题
- aws-api-gateway - api网关一直返回禁止
- string - List(Of String) Distinct 有重复项
- cmake - 使用 target_link_libraries 找到打印库完整路径
- reactjs - React setstate 会破坏 Redux 对象吗?
- python-3.x - PPTK,设置相机位置
- sql - 在 Label SQL 中添加点表示法