Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtualenv specific pip config files

I need to use different pip config files depending on which project I'm currently working on. Each project pulls from a separate pypi repo and needs its own block in my .pip/pip.conf file

[global]     timeout = 60     index-url = <my_custom_pypi_repo> 

Is there a way to provide a pip.conf file on a virtualenv specific basis?

Ideally when I run

 workon env1  pip install env1_package 

It would only try and download from the env1 config file

And similar for env2 Ideally when I run

 workon env2  pip install env2_package 

I would like it to not request this package from the env1 pypi server.

like image 319
Luke Exton Avatar asked Feb 25 '16 21:02

Luke Exton


People also ask

Where is pip config in VENV?

Inside a virtualenv: On Unix and Mac OS X the file is $VIRTUAL_ENV/pip. conf. On Windows the file is: %VIRTUAL_ENV%\pip. ini.

Where is pip config stored?

pip/pip. conf . The legacy “per-user” configuration file is also loaded, if it exists: $HOME/. pip/pip.

Where is pip config file Linux?

As stated in the documentation, the default locations for Linux are: per-user: $HOME/. config/pip/pip.


2 Answers

Found this after I had posted the question:

https://pip.pypa.io/en/stable/user_guide/#config-file

 ~/.pip/pip.conf 

You will need to set:

 ~/.virtualenvs/env1/pip.conf  ~/.virtualenvs/env2/pip.conf 

It will still inherit from:

 ~/.pip/pip.conf 

But will allow it to be overwritten for each environment.

like image 145
Luke Exton Avatar answered Oct 13 '22 03:10

Luke Exton


Just to update the answer here with the latest from the pip documentation:

Inside a virtualenv:

  • On Unix and macOS the file is $VIRTUAL_ENV/pip.conf

  • On Windows the file is: %VIRTUAL_ENV%\pip.ini

The $VIRTUAL_ENV environment variable gets set once you've activated the particular virtual environment you're interested in.

like image 41
sql_knievel Avatar answered Oct 13 '22 01:10

sql_knievel