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

2020-05-18 07:01发布

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?

11条回答
手持菜刀,她持情操
2楼-- · 2020-05-18 07:08

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

c:\Users\<UserName>\.pypirc      <- sic!, even on windows
查看更多
Lonely孤独者°
3楼-- · 2020-05-18 07:09

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
查看更多
时光不老,我们不散
4楼-- · 2020-05-18 07:10

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

查看更多
beautiful°
5楼-- · 2020-05-18 07:12

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'
查看更多
ら.Afraid
6楼-- · 2020-05-18 07:14

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

查看更多
戒情不戒烟
7楼-- · 2020-05-18 07:14

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

查看更多
登录 后发表回答