25

On my Mac, *nix based systems I configure pip by modifying the files:

  • ~/.pypirc
  • ~/.pip/pip.conf

The documentation that I've found so far, says that under windows you need to set the HOME environment variable and place the files in:

  • %HOME%\.pypirc
  • %HOME%\pip\pip.conf

However, this doesn't seem to work for me and when I try to use pip to install a package from one of our alternate servers the package can't be found. Any suggestions?

Links I've found so far

SiHa
  • 7,830
  • 13
  • 34
  • 43
aquil.abdullah
  • 3,059
  • 3
  • 21
  • 40

6 Answers6

11

The pip configuration docs at PyPA tell you to use a pip.ini file stored either:

  1. Globally at C:\ProgramData\pip\ (Win7 and up), or
  2. per-user at %HOME%\pip\ or
  3. per-virtualenv at the virtualenv root

In case of multiple pip.ini files, per-user settings override global settings. See the docs for more details.

Petri
  • 4,796
  • 2
  • 22
  • 31
  • I think this answers the title question "How to configure PYPI on Windows" better than the accepter answer, but the accepted one answers the question on how to install from a custom repo (which is only a small part of the PYPI configuration.) – Thomas Fauskanger Nov 30 '17 at 20:48
  • 2
    The (assumable later updtated) pip config docs mentioned in your answer now says in regard to per-user configuration: "On Windows the configuration file is ``%APPDATA%\pip\pip.ini``", but that the ``%HOME%\pip\pip.ini`` is a legacy location. – Thomas Fauskanger Nov 30 '17 at 20:52
  • Also, that "You can set a custom path location for this config file using the environment variable `PIP_CONFIG_FILE`" – Thomas Fauskanger Nov 30 '17 at 20:53
  • FWIW, I was able to figure out what pip.ini files already were expected to exist by this accepted answer: https://stackoverflow.com/questions/36569511/is-it-possible-to-get-pip-to-print-the-configuration-it-is-using , and when I discovered that none of them existed I created one using your answer. – Thomas Fauskanger Nov 30 '17 at 20:58
  • What about .pypirc? Can that configuration be placed inside of pip.ini?! – Robin De Schepper Oct 16 '19 at 15:37
  • for me, my pip.ini file locate at C:\Users\{{username}}\AppData\Roaming\pip – Xin Cai Apr 05 '20 at 22:39
  • This is confusing. Should it be `.pypirc` or `pip.ini`? – Alex Nov 11 '21 at 00:28
9

I was trying to work out where to put .pypirc on my Windows installation and the answer was C:\Users\YourName\.pypirc. Thanks Ernst Haagsman https://blog.jetbrains.com/pycharm/2017/05/how-to-publish-your-package-on-pypi/

hum3
  • 1,563
  • 1
  • 14
  • 21
7

I had a problem with this in Windows using setup.py. Getting the error:

ValueError: <repository> not found in .pypirc

From this I found that distutils only uses ~/.pypirc. And so you need to make the file %USERPROFILE%/.pypirc.

Peilonrayz
  • 3,129
  • 1
  • 25
  • 37
2

the easiest way to locate the folder is by running the following command in the cmd.

pip config -v list

That will result with the paths that pip is searching in to find the config file.

George Sotiropoulos
  • 1,864
  • 1
  • 22
  • 32
1

actually use:

pip config debug

to get all the locations and config details listed. try it out!

Siming Yan
  • 41
  • 4
0

I wasn't able to pip to use my mirror repos auto-magically just by setting up my configuration files, but I was able to use the repositories by using the -i option:

pip install -i http://url.to.my.repository package_name
aquil.abdullah
  • 3,059
  • 3
  • 21
  • 40