Python can't find the file pip.conf

浪子不回头ぞ 提交于 2021-02-06 09:58:49

问题


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


回答1:


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

  • per-user: $HOME/.config/pip/pip.conf
  • global: /etc/pip.conf



回答2:


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




回答3:


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



回答4:


just create it.~/pip/pip.conf




回答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!




回答6:


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.




回答7:


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




回答8:


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




回答9:


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



来源:https://stackoverflow.com/questions/38869231/python-cant-find-the-file-pip-conf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!