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

前端 未结 11 1987
谎友^
谎友^ 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:19

    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.

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

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

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

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

    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

    Inside a virtualenv:
    
    On Unix and macOS the file is $VIRTUAL_ENV/pip.conf
    On Windows the file is: %VIRTUAL_ENV%\pip.ini
    
    0 讨论(0)
  • 2021-01-31 08:27

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

    c:\Users\<UserName>\.pypirc      <- sic!, even on windows
    
    0 讨论(0)
  • 2021-01-31 08:31

    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

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