Search code examples
pythonpip

Is pip.conf broken? extra-index-url ignored


I'm running pip 24.0 on Ubuntu and have the following in ~/.pip/pip.conf:

[user]                                                                           
extra-index-url https://<MY_TOKEN_NAME>:<MY_TOKEN>@gitlab.com/api/v4/projects/<MY_PROJECT>/packages/pypi/simple
trusted-host = gitlab.com 

No other config files exist since pip config debug gives me:

global:
  /etc/xdg/xdg-ubuntu/pip/pip.conf, exists: False
  /etc/xdg/pip/pip.conf, exists: False
  /etc/pip.conf, exists: False
site:
  /usr/pip.conf, exists: False
user:
  /home/timo/.pip/pip.conf, exists: True
    user.extra-index-url https: //...
    user.trusted-host: gitlab.com
  /home/timo/.config/pip/pip.conf, exists: False

And pip config list correctly displays user.extra-index-url and user.trusted-host. But now when I run pip install --user <MY PACKAGE> -vv I get:

1 location(s) to search for versions of <MY PACKAGE>:
* https://pypi.org/simple/<MY PACKAGE>/

And my package is not found. When I pass --extra-index-url to pip directly it works as expected. I'm almost certain that this used to work in the past. Am I crazy or is this fundamental feature broken?


Solution

  • I suspect you confuse user config and [user] section. Change [user] to [global] or [install].

    See the docs at https://pip.pypa.io/en/stable/topics/configuration/

    Upd. BTW, you miss = after extra-index-url:

    extra-index-url = https://<MY_TOKEN_NAME>:<MY_TOKEN>@gitlab.com/api/v4/projects/<MY_PROJECT>/packages/pypi/simple`