Pip: ~/.pip/pip.conf and virtualenv conflict

Created on 2 Oct 2014  ·  5Comments  ·  Source: pypa/pip

I couldn't find this issue documented anywhere, but if you specify install-option in ~/.pip/pip.conf, it is not overriden by virtualenv. I specify --prefix=/path/to/somwhere in install-option due to user restrictions on my work pc, and with it set, any installs in a venv (with $PIP_RESPECT_VIRTUALENV enabled) still install in the path specified by install-option. This was not an expected behavior for me, but I'm not sure if ignoring pip.conf is the correct course of action either. Perhaps documenting such behavior is best. Another odd thing is that you then cannot uninstall while in the virtualenv, as the package is not installed in the venv, and pip cannot find it.

This happened to me when using pip 1.4.1 and 1.5.6 and virtualenv 1.11.6.

virtualenv needs repro bug

Most helpful comment

My current fix is to set $PIP_CONFIG_FILE to /dev/null via virtualenvwrapper's postactivate hook and unsetting it in postdeactivate.

All 5 comments

My current fix is to set $PIP_CONFIG_FILE to /dev/null via virtualenvwrapper's postactivate hook and unsetting it in postdeactivate.

This issue is still present. In my case, I'd like to use --user installs when not in a venv (via setting this in ~/.config/pip/pip.conf, but "normal" (in-venv) installs when in a venv (do --user installs even make sense in a venv?).

Two possible solutions (of which only the first one can really be implemented by pip, but I may as well start the discussion here) are

  • provide a configuration file location that is only used outside of venvs (~/.config/pip/pip-novenv.conf or whatever), or
  • make --user a no-op in a venv (again, I'm not sure --user + venv make sense: there's only one ~/.local/lib/pythonX.Y so all isolation is broken there).

Issue still present in Python 3.5.3.

It's pretty ironic and frustrating that if one tries to be careful with the environment, to the point of using virtual environments and user installs in pip.conf, one ends with a non-working system.

I was trying to avoid having team members use sudo pip. It keeps getting harder.

Isn't this a bug in virtualenv - that it doesn't set PIP_CONFIG_FILE=/dev/null when using some option?
Oh, got bitten by this today.

Can someone please provide clear instructions on how to reproduce this?

Was this page helpful?
0 / 5 - 0 ratings