ConfigParser is a Python module for reading and writing configuration files that have a structure similar to those of INI files in Microsoft Windows.
Questions tagged [configparser]
683 questions
5
votes
1 answer
Python ConfigParser - usage across modules
I'm trying to understand the best way to implement Python's ConfigParser so that elements are accessible to multiple program modules. I'm using:-
import ConfigParser
import os.path
config =…

Steve Crook
- 1,013
- 2
- 13
- 22
5
votes
1 answer
InvalidSchema("No connection adapters were found for {!r}".format(url)) while using the URL on requests module parsed by ConfigParser
I have an URL in the config file which I parsed using ConfigParser to get the requests
config.ini
[default]
root_url ='https://reqres.in/api/users?page=2'
FetchFeeds.py
import requests
from configparser import ConfigParser
import os
import…

Sam
- 61
- 1
- 1
- 6
5
votes
2 answers
pyinstaller cannot see configparser
I am using configparser in a python application
When I run the application
python main.py
it works. However if I use pyinstall to create a windows exe, the exe fails with the message
no module named 'configparser'
however as the screen shot shows,…

Psionman
- 3,084
- 1
- 32
- 65
5
votes
1 answer
ConfigParser in python 3 vs python 2
I've been slowly making the transition from py2 -> py3 and I've run into an issue that I can't quite resolve (as trivial as I'm sure the problem is). When I execute the code below, the config file appears to have no sections :(
Where have I gone…

SolipsisticAltruist
- 121
- 2
- 8
5
votes
1 answer
ConfigParser - Writing to .ini file
I have a config.ini file that has some default configuration for a web app (Flask using VS 2017)
I also want to write some configuration myself.
I am using the below code to try to write in the [keys] section, the variable being gkey:
def…

Brian
- 1,951
- 16
- 56
- 101
5
votes
2 answers
Storing and retrieving a list of Tuples using ConfigParser
I would like store some configuration data in a config file. Here's a sample section:
[URLs]
Google, www.google.com
Hotmail, www.hotmail.com
Yahoo, www.yahoo.com
Is it possible to read this into a list of tuples using the ConfigParser module? If…

Mridang Agarwalla
- 43,201
- 71
- 221
- 382
5
votes
1 answer
ConfigParser with no delimiter
Using Python 3.5 and ConfigParser.
I want to use a config file like this:
[Section]
key1
key2
key3
i.e. no values. By default ConfigParser requires values but I can pass allow_no_values=True to the constructor to handle that.
However the parser…

Zitrax
- 19,036
- 20
- 88
- 110
5
votes
3 answers
How to make a ConfigParser return a default value instead of raising a NoOptionError?
I have a config file with some options defined. Sometimes, if the requested option is not found, I want to ignore the error and return None.
setting.cfg:
[Set]
ip=some_ip
verify=yes #if verify does not exist here -->…

Dave
- 221
- 2
- 12
5
votes
2 answers
python RawConfigParser
I'm using the RawConfigParser to read and update an ini style configuration file. This works all without problems in the standard configuration.
My problem is that I'm reading different config files in the same script. Without going too much into…

Johan De Pontieu
- 55
- 1
- 7
5
votes
2 answers
Python configparser error after Yosemite install
I've upgraded to Yosemite and this seems to have broken my python modules.
python --version == Python 2.7.6
Then from the Python shell:
>>> import pyrax
Traceback (most recent call last):
File "", line 1, in
File…

Jason Prawn
- 1,003
- 11
- 20
5
votes
1 answer
Handling duplicate keys with ConfigParser
Possible Duplicate:
Python Config Parser (Duplicate Key Support)
I'm trying to read an INI format project file in Python. The file contains duplicate keys (having unique values) within a section. For example, one of the sections looks like…

Praetorian
- 106,671
- 19
- 240
- 328
4
votes
3 answers
Adding comment with configparser
I can use the ConfigParser module in python to create ini-files using the methods add_section and set (see sample in http://docs.python.org/library/configparser.html). But I don't see anything about adding comments. Is that possible? I know about…

Niclas Nilsson
- 5,691
- 3
- 30
- 43
4
votes
3 answers
How to convert a string to tuple
I like to convert in a Python script the following string:
mystring='(5,650),(235,650),(465,650),(695,650)'
to a list of tuples
mytuple=[(5,650),(235,650),(465,650),(695,650)]
such that
print mytuple[0] yields:
(5,650)

Jean-Pat
- 1,839
- 4
- 24
- 41
4
votes
2 answers
Configparser Occasionally Returns Empty Result
I am reading configurations from an ini file using Python configparser. 95% of the time, it works perfectly. Without any changes to the ini file (e.g., in the middle of a regression test), configparser will start returning empty results, and then of…

CoderOfTheNight
- 944
- 2
- 8
- 21
4
votes
2 answers
Read and update git config with python?
I tried configparser, but it does not respect indentation for git config files (git config files have indentation inside sections as opposed to linux usual format without indentation). After I update config file, all indentation is gone.
There is…

Andrius
- 19,658
- 37
- 143
- 243