Search code examples
pythonconfigparser

ConfigParser library not working when using with python3


I am using and importing ConfigParaser

import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('Config.properties')
timeout_val=config.get('Section', 'commandtimeout') 

and install it using,

pip install ConfigParser

While running the python script getting below mention error.

Traceback (most recent call last):
  File "system_offline.py", line 41, in <module>
    import ConfigParser
ImportError: No module named 'ConfigParser'

Now, my question is if run the same program using python 2.7 at the same system, above import statement works with out issue.

Wondering what needs to be done for this program to run with python3?

Edit: While using python 2.7 it is working but with python3, i am getting above mention error.


Solution

  • The ConfigParser module was renamed to configparser in Python 3.0.