Python - cant find pip.ini or pip.conf in Windows

WindowsPython 2.7ConfigurationPip

Windows Problem Overview


I got Python 2.7.8 installed on my Win7 machine, which comes with pip already pre-installed.
I'm successfully able to install new packages from pip and now I need to add custom repository url to the install list of pip

To do so I need to modify pip.ini which is in %APPDATA%\pip\pip.ini according to the Official Manual
However there are no pip folder anywhere (not in Roaming, not in Local, not in LocalLow) nor there exists PyPa folder in: C:\ProgramData\PyPA\pip\pip.conf

Could you tell me where do i search for pip.ini? how to add foreign repo to the install list?

Windows Solutions


Solution 1 - Windows

Instead of checking a list of well-known locations, you can ask pip to list the valid locations:

pip config -v list

Fun fact

On the same machine, with the same pip version, the valid locations can vary based on the actual Python version.

Environment: Win 7 x64, the HOME environment variable is set to D:\Home

Python 3.7.3:

> pip config -v list
For variant 'global', will try loading 'C:\ProgramData\pip\pip.ini'
For variant 'user', will try loading 'D:\Home\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\foobar\AppData\Roaming\pip\pip.ini'
For variant 'site', will try loading 'C:\Python37\pip.ini'

Python 3.8.0:

> pip config -v list
For variant 'global', will try loading 'C:\ProgramData\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\foobar\pip\pip.ini'
For variant 'user', will try loading 'C:\Users\foobar\AppData\Roaming\pip\pip.ini'
For variant 'site', will try loading 'C:\Python38\pip.ini'

Solution 2 - Windows

Finally got it sorted.

Apparently for Windows users pip.ini config file is not created, however can be added manually!

just create new %APPDATA%\pip\pip.ini and content of custom repository:

[install]
find-links = https://<login>:<password>@your.repo.com/custom/url

Reference: https://pip.pypa.io/en/stable/user_guide/#config-file

Solution 3 - Windows

A bit late, but for reference: Try adding the pip.ini file in %USERPROFILE%\pip\pip.ini (usually: C:\Users\<username>\pip\pip.ini).

Solution 4 - Windows

On windows pip.exe looks for "pip.ini" in this order:

C:\ProgramData\pip\pip.ini
C:\Users\<username>\pip\pip.ini
C:\Users\<username>\AppData\Roaming\pip\pip.ini

Solution 5 - Windows

Pip changed the location of the config file in windows starting in pip 6.0 the pip config docs explain the location of the config files as follows.

pip --version >= 6 (as of version 18.1 hasn't changed again yet)
%APPDATA%\pip\pip.ini
pip --version < 6
%HOME%\pip\pip.ini
Inside a virtual env
%VIRTUAL_ENV%\pip.ini
Site-wide win7+ (same as of win10)
C:\ProgramData\pip\pip.ini
Site-wide winxp (note windows vista side wide not supported)
C:\Documents and Settings\All Users\Application Data\pip\pip.ini
NOTE: If multiple configuration files are found by pip then they are combined in the following order:
  1. The site-wide file is read
  2. The per-user file is read
  3. The virtualenv-specific file is read

Also pip added a config command starting in pip 10.

pip config --help

Solution 6 - Windows

It's been 7 years, and I think there's now a better answer for most people -- but it does depend on version of pip. For the most recent pips I'm using:

    $ pip config -v debug

lists where it's looking and you can decide which location is most useful for what you've got in mind. It does look like a fairly recent change: On a year-old docker image I had with pip 20.1 I got "ERROR: Need an action (edit, get, list, set, unset) to perform." On that system, pip config -v list gave a list of files it would try, this is supposed to be 'global', 'user' or 'site' variants of pip.ini locations.

For Windows 10, for pip 21.2.4 on both 3.9.6 and 3.6.8, I get response below with pip config -v debug, while pip config -v list is silent (unless a pip.ini is found).

global:
  C:\ProgramData\pip\pip.ini, exists: False
site:
  c:\py\myvenv\pip.ini, exists: False
user:
  C:\Users\myname\pip\pip.ini, exists: False
  C:\Users\myname\AppData\Roaming\pip\pip.ini, exists: False

From a downloaded image I got from dockerhub in June 2021 with pip 21.2.2 and python 3.6.10:

 pip config -v debug
 env_var:
 env:
 global:
   /etc/xdg/pip/pip.conf, exists: False
   /etc/pip.conf, exists: True
 global.extra-index-url: http://trynexs:8081/repository/repo_group/simple
 site:
   /usr/local/pip.conf, exists: False
 user:
   /home/tanhauser/.pip/pip.conf, exists: False
   /home/tanhauser/.config/pip/pip.conf, exists: False

Solution 7 - Windows

I know this is a bit late, however, this post is high on the rankings when searching. Inside a virtual environment pip.ini can also be in the root of the virtual environment. From the docs and https://pip.pypa.io/en/stable/user_guide/?highlight=pip.ini#configuration

Inside a virtualenv:

On Unix and macOS the file is $VIRTUAL_ENV/pip.conf
On Windows the file is: %VIRTUAL_ENV%\pip.ini

Solution 8 - Windows

All the answers are partially wrong and right. It depends on how your system is configured. The only way (for me) to find out was to patch site-packages/pip/locations.py at the point where site_config_files is assigned (around line 120 for pip 9.0.1)

> print('########## ' + str(site_config_files))

and then run pip search foo

On my system it printed ########## ['C:\\ProgramData\\pip\\pip.ini'], of which location I assumed I could not create/edit. But it just worked.

Btw, for my system %APPDATA% points to C:\Users\MYUSER\AppData\Roaming, which is not looked at when running pip on my system.

Solution 9 - Windows

Rather than guessing first check if you have any default global/local config which is read by pip with the below command:

pip config list

This will give all details of the default config loaded by python.

If the above command doesn't give any output please try to find where pip tries to find for the global config file with the below command:

pip config --editor <path to editor of your choice> edit

The above command will open the config file which pip reads by default or else it will give an error saying that the file doesn't exist.

If there's an error please go ahead and create the exact directory and file structure as show in the error. Once the file has been created please make your changes e.g.

[global]
cert = /path/to/base64/ssl/certificate.pem
proxy = http://username:password@ipaddress:port

Save the file and please try to check (the above mentioned check command) if the configs are loaded by pip or not.

For more info please follow pip config documentation

Solution 10 - Windows

Make sure you acually have a pip.ini file, not pip.ini.txt.

Solution 11 - Windows

For me (Windows 8, pip 9.0.1, python 3.5.3), the correct path was

c:\Users\<UserName>\.pypirc      <- sic!, even on windows

Solution 12 - Windows

Windows 10:

I had to create 'pip' directory inside

C:\Users\UserName\AppData\Roaming\

then create pip.ini file inside that 'pip' directory:

C:\Users\<username>\AppData\Roaming\pip\pip.ini

No other location worked for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBriksinsView Question on Stackoverflow
Solution 1 - WindowsalexandrulView Answer on Stackoverflow
Solution 2 - WindowsBriksinsView Answer on Stackoverflow
Solution 3 - WindowsMoshe ZviView Answer on Stackoverflow
Solution 4 - WindowsSirmabusView Answer on Stackoverflow
Solution 5 - WindowsPyklerView Answer on Stackoverflow
Solution 6 - WindowsLevin MagruderView Answer on Stackoverflow
Solution 7 - WindowsAMGView Answer on Stackoverflow
Solution 8 - WindowsWolfgang KuehnView Answer on Stackoverflow
Solution 9 - WindowsskapView Answer on Stackoverflow
Solution 10 - WindowsBendik KnapstadView Answer on Stackoverflow
Solution 11 - WindowsTommyView Answer on Stackoverflow
Solution 12 - WindowskujawView Answer on Stackoverflow