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:
On Mac OS X the configuration file is $HOME/Library/Application Support/pip/pip. conf. On Windows the configuration file is %APPDATA%\pip\pip. ini.
It contains configuration on how to access specific PyPI index servers when publishing a package. pip. conf on the other hand is only used by the pip tool, and pip never publishes packages, it downloads packages from them. As such, it never looks at the .
Config file locations are documented https://pip.pypa.io/en/stable/user_guide/#config-file. For me, it was located in /etc/pip.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With