52

I can't find the file pip.conf in the path ~/.config/pip/pip.conf or the path ~/pip/pip.conf. My version of pip is 8.1.2

user
  • 1,220
  • 1
  • 12
  • 31
user5324426
  • 693
  • 1
  • 5
  • 12

11 Answers11

57

Use the pip to retrieve its location, here is the trick!

python3 -m pip config debug

It will list global and local env, If it set or otherwise.

Ahmed Contrib
  • 646
  • 4
  • 5
53

As stated in the documentation, the default locations for Linux are:

  • per-user: $HOME/.config/pip/pip.conf
  • global: /etc/pip.conf
Pete Kirkham
  • 48,893
  • 5
  • 92
  • 171
xystum
  • 939
  • 6
  • 8
  • 12
    Beware! pip 20.0 (used in Ubuntu 20.04) has a bug, where it doesn't read /etc/pip.conf, but only /etc/xdg/pip/pip.conf. This bug was fixed in pip 20.1, but the fix is currently not available in the pip package for Ubuntu 20.04. – Enno Gröper May 13 '20 at 14:57
  • 2
    it's worth noticing in those same docs that there is a third option to have a per-virtualenv configuration at `$VIRTUAL_ENV/pip.conf`. – vlizana Aug 26 '20 at 20:12
  • @EnnoGröper Do you know if there is an Ubuntu bug report for this? I can't seem to find one. – Michael Feb 02 '21 at 22:05
  • What about per venv? where is the pip conf of the current venv? – Gulzar Dec 13 '22 at 12:13
24

https://pip.pypa.io/en/stable/user_guide/#configuration

If you do not have the pip.conf by default, create it on your desired directory and do the export.

export PIP_CONFIG_FILE=/path/to/pip.conf
9

Before creating pip.conf I would rather check with the following command before creating one

find . -name 'pip.conf'

For me it was under home directory as

./Library/Application Support/pip/pip.conf

Raj Hassani
  • 1,577
  • 1
  • 19
  • 26
  • 1
    I've found it in `/home/$user_name/.config/pip/pip.conf` using your command. I'm running a Linux machine. – yosra Jun 25 '19 at 09:07
9

Another solution not found in any of the answers about finding the pip.conf files currently used by pip:

pip config list

if no file is described you should follow most of the other answers and just create it on your own

kaki gadol
  • 1,116
  • 1
  • 14
  • 34
6

just create it.~/pip/pip.conf

LF00
  • 27,015
  • 29
  • 156
  • 295
5

I am using WSL ubuntu on win10, with only official python3-pip, and cannot find any pip.conf.

I just create ~/.pip/pip.conf, and then it speeds up my sudo pip3 install --upgrade pip!

Choi
  • 389
  • 3
  • 6
3

According to the docs, it could be located in a multitude of places.

In terms of flexibility, I say the section about installing it on virtual environments is probably the most flexible IMO.

If you use a virtual environment for your python projects, then it may be desirable to have your pip.conf inside the virtual environment, than to have it sitting in your home directory.

The reason for this is simple. Say for example you have special projects that require specific pip.conf setup and you don't want to put the configurations for these projects in the pip.conf in your home directory or the global one, then you might find it makes life easier to create a dummy environment where this configuration lives and simply copy that environment for each new "secret" project.


Virtualenvwrapper

I will propose a simple way to achieve this with virtualenvwrapper:

mkvirtualenv --python=/path/to/python _python_project_base
cp ~/my_secret_pip.conf $VIRTUAL_ENV/pip.conf

There, that was easy.

What this allows you to do is that when next you want to create a new project, instead of using mkvirtualenv, you simply do:

cpvirtualenv _python_project_base new_virtual_env_name
setvirtualenvproject new_virtual_env_name /path/to/project_folder

And voila, the same pip.conf follows you everywhere, and you don't have to worry about polluting your other config files outside the virtual environment.

smac89
  • 39,374
  • 15
  • 132
  • 179
1

copy your config file to /etc/pip.conf

this will make it apply for every user

There is a chance that your local user doesn't have read permissions on your pip.conf.

sudo chmod 644 /etc/pip.conf

semiga
  • 11
  • 1
1

For Windows, it can be found at %AppData%\Roaming\pip\pip.ini (pip version 20.0.2)

Here are some other helpful answers for Windows users: Python - cant find pip.ini or pip.conf in Windows

sorifiend
  • 5,927
  • 1
  • 28
  • 45
0

I experienced the same issue. I was trying to install a venv on my allocation on a compute cluster system. What worked for me was to do the following before creating the venv.

unset PIP_CONFIG_FILE
julio514
  • 181
  • 1
  • 1
  • 13