I have installed configparser using "pip install configparser" to get configparser-3.5.0, and is on my PYTHONPATH. But when i use it as "import configparser", i am seeing an error "No module named backports.configparser". conigparser.py use this 'backports' module and I see the 'backports' module under the python path but somehow it is unable to identify that module. Can someone give me an idea about how shall i fix this? This certainly looks to me some version problem of configparser, but I did not find any answers so far. Help will be appreciated, thanks
-
I can't reproduce in a fresh python2 virtualenv with `pip install configparser` – anthony sottile Jul 26 '17 at 16:23
-
Hmm, interesting. I have python 2.7.6 and getting that. Do you suggest any thing to get rid of that, may be upgrade configparser? – user3339691 Jul 26 '17 at 17:42
-
Do you actually need the python3 features? In python2 `ConfigParser` is a stdlib module (renamed to `configparser` in python3) – anthony sottile Jul 26 '17 at 17:44
-
not really i need python3 features, but i just did pip install configparser and i got configparser that what i have. I just need to use couple of functions from configparser. How can i get ConfigParser instead of configparser? – user3339691 Jul 26 '17 at 18:41
-
I was able to fix it by installing pip install configparser==3.3.0.post2, thanks for the input – user3339691 Jul 27 '17 at 00:46
-
`ConfigParser` is part of the stdlib in python2, just `import ConfigParser` where you were importing `configparser` (note that it won't have the new python3 features as the backport will) – anthony sottile Jul 27 '17 at 15:23
-
@Anthony Sottile, python2 (no virtualenv, no conda) notebook ... -> `entrypoints.py`: `if sys.version_info[0] >= 3: import configparser else: from backports import configparser` – denis Oct 29 '17 at 12:22
4 Answers
I was able to fix it by using:
pip install configparser==3.3.0.post2

- 6,856
- 5
- 41
- 53

- 455
- 2
- 5
- 16
-
Thanks -- do you have any further information on how you arrived at this solution? – aJetHorn Jan 17 '18 at 22:58
-
i guess by trying minor versions from https://pypi.org/project/configparser/#history – evandrix Jan 08 '20 at 08:17
If you are using anaconda, install configparser can solve the issue.
conda install -c anaconda configparser
Solving environment: done
## Package Plan ##
environment location: /Users/kaituo/anaconda2
added / updated specs:
- configparser
The following packages will be downloaded:
package | build
---------------------------|-----------------
conda-4.5.4 | py27_0 1.0 MB anaconda
configparser-3.5.0 | py27hc7edf1b_0 35 KB anaconda
certifi-2018.4.16 | py27_0 142 KB anaconda
openssl-1.0.2o | h26aff7b_0 3.4 MB anaconda
ca-certificates-2018.03.07 | 0 124 KB anaconda
------------------------------------------------------------
Total: 4.7 MB
The following packages will be UPDATED:
ca-certificates: 2018.03.07-0 --> 2018.03.07-0 anaconda
certifi: 2018.4.16-py27_0 --> 2018.4.16-py27_0 anaconda
conda: 4.5.4-py27_0 --> 4.5.4-py27_0 anaconda
configparser: 3.5.0-py27hc7edf1b_0 --> 3.5.0-py27hc7edf1b_0 anaconda
openssl: 1.0.2o-h26aff7b_0 --> 1.0.2o-h26aff7b_0 anaconda
Proceed ([y]/n)? y
Downloading and Extracting Packages
conda-4.5.4 | 1.0 MB | ########################################################################################################################################### | 100%
configparser-3.5.0 | 35 KB | ########################################################################################################################################### | 100%
certifi-2018.4.16 | 142 KB | ########################################################################################################################################### | 100%
openssl-1.0.2o | 3.4 MB | ########################################################################################################################################### | 100%
ca-certificates-2018 | 124 KB | ########################################################################################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

- 347
- 3
- 7
I had this problem as well today with python-2.7.6.
I fixed it by creating an empty __init__.py
in the <install_location>/configparser/backports
directory.
The pip install did not create it.
We had another version installed by setup.py in a different location which did have the __init__.py
file.

- 31
- 6
Just in case none of the solutions above work.
The easiest and probably the most reliable one would be to install backports.configparser
directly from the source.
See: https://github.com/jaraco/configparser
You can do so by performing;
python setup.py install
Note that: Doing so means that you will be installing one of the latest released version. If your work demands you to use a specific version then you'll have to checkout
the right version before installing.

- 18,006
- 3
- 24
- 39