ConfigParser Installation Error – python setup.py egg_info failed with error code 1 [Solved]

Updated on September 2, 2017

Error: The packstack command failed with an error message as “ImportError: No module named ConfigParser”. So I tried installing ConfigParser using Python PIP, but the installation failed as shown below.

$pip install ConfigParser
Collecting ConfigParser
 Downloading configparser-3.3.0r2.tar.gz
 Complete output from command python setup.py egg_info:
  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

What could be the problem?

python module install error

Solution:

I googled and found a post@StackOverflow – where the best answer says “In Python version 3.x, ConfigParser module has been renamed to configparser as part of PEP (Python Enhancement Proposals) 8

It means, the package being installed does not support Python version 3.x. Well, I recently installed Python 3.5.1 – I’ll revert it back to older version of Python and see if the error goes off.

Check Python version

$python --version
Python 3.5.1

And had linked /usr/local/bin/python to python3.5.

ls -l /usr/local/bin/python
lrwxrwxrwx 1 root root 9 Dec 11 15:19 /usr/local/bin/python -> python3.5

Linking python back to Python 2.7

I’ll now revert python back to Python version 2.7 and see if I can install ConfigParser.

$unlink python
$ln -s /usr/local/bin/python2.7 python
$ls -l python
lrwxrwxrwx 1 root root 24 Jan 6 18:53 python -> /usr/local/bin/python2.7

Installing ConfigParser via pip install

Now, the default python command is linked to python2.7. Let’s install ConfigParser

$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

Viola! It worked.

Was this article helpful?

Related Articles

Comments Leave a Comment

  1. Python 2.7 is obsolete and deprecated. Any proposed solution to this problem must use a Python3 version.

Leave a Comment