python 2.7:没有名为 configparser 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31662194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 10:22:35  来源:igfitidea点击:

python 2.7: no module named configparser

pythonflasksqlalchemy

提问by fstopzero

I'm trying to run db_create.pyin Flask, and am getting the following error:

我正在尝试db_create.py在 Flask 中运行,但出现以下错误:

from six.moves.configparser import ConfigParser
ImportError: No module named configparser

Even after a successfull pip install, the same error code comes up.

即使在成功之后pip install,也会出现相同的错误代码。

I'm seeing solutions targeting Python 3, but not lower.

我看到了针对 Python 3 的解决方案,但不是更低。

采纳答案by lemonhead

For anyone following along, this was likely caused by an old (broken) version of the sixmodule, e.g. see https://github.com/Parsely/streamparse/issues/113, for instance

对于下面沿着任何人,这很可能由一个旧(坏)版本引起的six模块,如见https://github.com/Parsely/streamparse/issues/113,例如

which caused six.movesto be almost empty (contained no configparsermodule)

这导致six.moves几乎是空的(不包含configparser模块)

The fix was to upgrade the version of sixused.

修复是升级使用的版本six

回答by Miguel ángel FT

I am using CENTOS RHEL 7 with Python 2.7.5 & pip version 8.1.2 and and fixed it doing:

我将 CENTOS RHEL 7 与 Python 2.7.5 和 pip 版本 8.1.2 一起使用,并修复了它:

cd /home/user/
sudo pip install configparser

And it was done for me. But Previously i had installed:

它是为我完成的。但以前我安装过:

cd /home/user/
pip install --user pytz requests tqdm tzlocal python-dateutil

No problems at all.

完全没有问题。

to know your python version and to know configparser check up:

了解您的 python 版本并了解 configparser 检查:

python --version

python -c 'import six; print(six.__version__)'

python -c 'import six.moves; print(dir(six.moves))'

I had configparser installed previously but I was not working so I think you must install all the dependencies and libs of python pip on your /home/user_directory

我之前安装了 configparser 但我没有工作,所以我认为你必须在你的计算机上安装 python pip 的所有依赖项和库/home/user_directory