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

前端 未结 11 1989
谎友^
谎友^ 2021-01-31 07:57

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 c

相关标签:
11条回答
  • 2021-01-31 08:32

    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
    
    0 讨论(0)
  • 2021-01-31 08:33

    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.

    0 讨论(0)
  • 2021-01-31 08:35

    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'
    
    0 讨论(0)
  • 2021-01-31 08:35

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

    0 讨论(0)
  • 2021-01-31 08:39

    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

    0 讨论(0)
提交回复
热议问题