使用数据库.gnu对于python3.6.8 on m

2024-04-20 03:19:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我在使用数据库.gnu对于macOS上的Python3.6.8。我已经用conda在我的Python虚拟环境中安装了gdbm。。。但是当我试图调用数据库.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

有什么可靠的方法让它工作吗?当从astropy调用download_file时,我可以通过设置cache = False来关闭缓存。。。但我真的想设置cache = True。任何帮助都将不胜感激。在


Tags: theinpycachelibopenfilenameprotocol
1条回答
网友
1楼 · 发布于 2024-04-20 03:19:18

所以我最后做了一件不明智但有效的事情,那就是更改“/anaconda3/envs/py36 stable/lib/python3.6/dbm”中的唯一一行/gnu.py“从

from _gdbm import *

^{pr2}$

。。。这对我很有帮助。在

相关问题 更多 >