Is it possible to get pip to print the configuration it is using?
Is there any way to get pip to print the config it will attempt to use? For debugging purposes it would be very nice to know that:
- config.ini files are in the correct place and pip is finding them.
- The precedence of the config settings is treated in the way one would expect from the docs
For 10.0.x and higher
There is new pip config
command, to list current configuration values
pip config list
(As pointed by @wmaddox in comments) To get the list of where pip looks for config files
pip config list -v
Pre 10.0.x
You can start python console and do. (If you have virtaulenv don't forget to activate it first)
from pip import create_main_parser
parser = create_main_parser()
# print all config files that it will try to read
print(parser.files)
# reads parser files that are actually found and prints their names
print(parser.config.read(parser.files))
create_main_parser
is function that creates parser
which pip uses to read params from command line(optparse
) and loading configs(configparser
)
Possible file names for configurations are generated in get_config_files
. Including PIP_CONFIG_FILE
environment variable if it set.
parser.config
is instance of RawConfigParser
so all generated file names in get_config_files
are passed to parser.config.read
.
Attempt to read and parse a list of filenames, returning a list of filenames which were successfully parsed. If filenames is a string, it is treated as a single filename. If a file named in filenames cannot be opened, that file will be ignored. This is designed so that you can specify a list of potential configuration file locations (for example, the current directory, the user’s home directory, and some system-wide directory), and all existing configuration files in the list will be read. If none of the named files exist, the ConfigParser instance will contain an empty dataset. An application which requires initial values to be loaded from a file should load the required file or files using read_file() before calling read() for any optional files: