首页 > 解决方案 > 由 conda 安装时 python2.7 缺少标准 dbm 模块

问题描述

我想通过 conda 安装 python2.7,如下命令:

conda create -n tensorflow python=2.7 anaconda

但它缺少dbm模块。

$  python
Python 2.7.15 | packaged by conda-forge | (default, Jul  2 2019, 00:39:44) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbm
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named dbm
>>> import Tkinter
>>> 

然后我尝试安装python-gdbmgoogle和stackoverflow的建议。

$ conda install -n tensorflow -c anaconda python-gdbm
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /public/home/miniconda2/envs/tensorflow

  added / updated specs:
    - python-gdbm


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2019.11.28         |           py27_0         156 KB  anaconda
    python-gdbm-1.1            |           py27_0          21 KB  anaconda
    ------------------------------------------------------------
                                           Total:         177 KB

The following NEW packages will be INSTALLED:

  gdbm               anaconda/linux-64::gdbm-1.12-0
  python-gdbm        anaconda/linux-64::python-gdbm-1.1-py27_0

The following packages will be UPDATED:

  openssl            conda-forge::openssl-1.1.1d-h516909a_0 --> anaconda::openssl-1.1.1-h7b6447c_0

The following packages will be SUPERSEDED by a higher-priority channel:

  ca-certificates    conda-forge::ca-certificates-2019.11.~ --> anaconda::ca-certificates-2019.11.27-0
  certifi                                       conda-forge --> anaconda


Proceed ([y]/n)? y


Downloading and Extracting Packages
python-gdbm-1.1      | 21 KB     | ################################################################################################################################ | 100% 
certifi-2019.11.28   | 156 KB    | ################################################################################################################################ | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

不幸的是,当import dbm.

任何帮助深表感谢。谢谢。

标签: python-2.7tensorflowcondadbm

解决方案


AFAIK,没有支持dbmLinux 模块的 Anaconda(或 Conda Forge)Python 2.7 构建(例如,请参阅此问题)。该anaconda::python-gdbm包应提供功能,但导入将是:

import gdbm

推荐阅读