python 运行报错 no module named configparser

no module named configparser完全不明白这是什么意思。configparser又是什么?

python 运行报错 no module named configparser是设置错误造成的,解决方法为:

1、根据提示,Python缺少rar模块,这种情况下,应先在py官网下载rarfile压缩包,如:rarfile-3.1.tar.gz。

2、首先,运行——cmd。

3、然后打开rarfile的路径,如:cd C:\Users\Administrator\Desktop\python\rarfile-3.1。

4、然后,输入:Python setup.py install 回车  安装rar模块。

5、然后,安装完成如图,如果这一步报错,则可能是没有安装Python,或者是没有配置Python环境。

6、最后,重新打开cmd,先输入Python,回车,再输入 import rarfile 不会报错,让人模块安装成功。

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-10-01
>>> import configparser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named configparser

因为你没有这个类,python有个类名字叫ConfigParser ,是用来做配置解析的

不过看你这情况有可能是拼写错误,应当为大写的ConfigParser

追问

你上面截图都是小写。没这个类的我应该怎么办呢

追答

我的截图是演示了可以出现相同错误的情况

你可以看看代码里面有没有类似的使用,把他修改为

 import ConfigParser

试试

追问

尴尬的就在这。。。。代码肯定没问题,因为公司别的机子都能跑。就我的不行,然后就各总装框架。配各种环境。。。会不会是没装什么。我用eclipse运行的python2,7。。。我也试着加了这一句。还是一样的错,

追答

就我所知 python 3.2 以后的版本中 ,应当使用import configparser

如果是python 2.7 使用为 import ConfigParser

Note

The ConfigParser module has been renamed to configparser in
Python 3. The 2to3 tool will automatically adapt imports when
converting your sources to Python 3.

在3以上版本中改名为全小写的了,估计代码可以在python 3上运行,python 2 不行

本回答被提问者和网友采纳
第2个回答  2021-06-10
用python3执行py文件,例:python3 test.py,确认你的python是python3版本。