How to Solve ImportError: No module named ConfigParser?

Updated on November 1, 2017

Question: I was stuck with an error ImportError: No module named ConfigParser when I run packstack command in CentOS. Below is the complete error message:

$packstack --gen-answer-file=answers.txt
Traceback (most recent call last):
 File "/usr/local/bin/packstack", line 4, in <module>
 __import__('pkg_resources').run_script('packstack==7.0.0', 'packstack')
 import ConfigParser
ImportError: No module named 'ConfigParser'

Can you tell me how to solve this issue?

no module error solution

Solution:

As the error says, the packstack command is not able to load one of the Python module named ConfigParser. It means, you have to install ConfigParser module. I suggest you to install Python PIP, which allows you to install modules quite easily. Once you have PIP installed, below is the command to install ConfigParser module.

$pip install configparser
Collecting configparser
Using cached configparser-3.3.0r2.tar.gz
Building wheels for collected packages: configparser
Running setup.py bdist_wheel for configparser
Stored in directory: /root/.cache/pip/wheels/1a/3e/f9/d34006ad6b1edfe5006aa704f5ee305c553344a7a6d8550c29
Successfully built configparser
Installing collected packages: configparser
Successfully installed configparser-3.3.0.post2

Note: In case, if pip install configparser failed with an error as shown below:

$pip install ConfigParser
Collecting ConfigParser
Downloading configparser-3.3.0r2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/local/lib/python3.5/site-packages/setuptools/__init__.py", line 5, in <module>
import distutils.core
File "/usr/local/lib/python3.5/distutils/core.py", line 18, in <module>
from distutils.config import PyPIRCCommand
File "/usr/local/lib/python3.5/distutils/config.py", line 7, in <module>
from configparser import ConfigParser
File "/tmp/pip-build-vks_efrb/ConfigParser/configparser.py", line 397
_KEYCRE = re.compile(ur"%\(([^)]+)\)s")
^
SyntaxError: invalid syntax----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-vks_efrb/ConfigParser

Then click here to fix the issue.

Other no module named errors & fixes

Was this article helpful?

Related Articles

Comments Leave a Comment

  1. you just tell people to install missing modules. that’s not an exhaustive solution

  2. After doing pip install configparser and getting a successful install message, python prog still reports “No module named configparser” when I try to run it!

  3. After doing pip install configparser and getting a successful install message, python prog still reports “No module named configparser” when I try to run it!

Leave a Comment