Unknown user-based global PIP configuration sets wrong PyPi registry

Question:

I used to need to install all PIP packages from a private repository (that mirrored pypi.org but also contained some of our own packages).

To ensure that pip install <package> would always resolve all packages from this repository, I created a file named ~/.pypirc with this content:

[distutils]
index-servers = 
    nexus
    nexus-own

[nexus]
repository = https://nexus.REDACTED.com/repository/pypi/
username = REDACTED
password = REDACTED

[nexus-own]
repository = https://nexus.REDACTED.com/repository/our-pypi/
username = REDACTED
password = REDACTED

However, the process has now been changed and the specified repository doesn’t exist any more.

I deleted the .pypirc file but still, pip will try to resolve packages from the private repository.

For my own projects I can circumvent this by explicitly stating pypi.org as repository in the Pipfile, but when I want to install a package globally, it will fail because it will try to access the now-defunct repository:

Looking in indexes: https://REDACTED:****@nexus.REDACTED.com/repository/pypi/simple
Collecting PACKAGE_NAME_REDACTED
  Downloading PACKAGE_NAME_REDACTED
     - 193.2 kB 2.7 MB/s 0:00:00
  ERROR: Cannot unpack file /private/var/folders/yg/c7k3cx_s105249_xfk0rz8vr0000gp/T/pip-unpack-pyy2dbxl/REDACTED.git (downloaded from /private/var/folders/yg/c7k3cx_s105249_xfk0rz8vr0000gp/T/pip-req-build-sqsbu7rx, content-type: text/html; charset=utf-8); cannot detect archive format

How can this be now that the .pypirc file has been removed?

Does pip cache this information anywhere? I’ve searched my complete user’s home directory recursively but could not find any trace of this configuration.

Where could pip be getting it from?

How can I make pip revert back to the default settings with pypi.org as default repository?

This only affects one user; if I login as a different user, I can install packages from pypi.org withouth problems.

My local system is macOS 13.2.1. Ventura.
Pip version is 22.3.1.
Python version is 3.11.4

Asked By: ronin667

||

Answers:

pip doesn’t consult with .pypirc, twine does when uploading packages.

pip when downloading consults with pip.conf. To list your configuration files run

pip config debug

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

Answered By: phd
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.