On a case-sensitive environment, HTTP_PROXY and http_proxy can be distinct names. ConfigParser normally lowercases option names, so feeding both into its defaults can turn them into one duplicate option.

An error naming <dict> can therefore originate from ConfigParser(defaults=os.environ), before any proxy connection is attempted.

If the application intentionally needs case-sensitive environment names in this parser, set the normalization policy before loading them:

import configparser
import os

settings = configparser.ConfigParser(interpolation=None)
settings.optionxform = str
settings.read_dict({'DEFAULT': dict(os.environ)})

This keeps the two spellings separate. Lookups and any subsequently read configuration now follow that case-sensitive policy too. Disabling interpolation also prevents percent signs in environment values from being treated as interpolation syntax.

If the application requires case-insensitive configuration, select the intended environment inputs explicitly and resolve conflicting spellings according to that client's proxy rules before passing them to the parser.

Changing strict=False accepts duplicates but does not define which conflicting proxy value the application should use. Removing one accidental environment spelling can be appropriate when you do not control the parser; first identify which value the downstream client needs.

Related articles